<commit_before>﻿using System;
using System.Collections; 
using System.Collections.Generic;
using System.Linq;

using TSF.UmlToolingFramework;

namespace TSF.UmlToolingFramework.UML.Extended {

  public abstract class UMLFactory {
    private static Dictionary<UMLModel, UMLFactory> instances = 
      new Dictionary<UMLModel,UMLFactory>();

    private static void addFactory(UMLModel model, UMLFactory factory) {
      if (!instances.ContainsKey(model)) {
        instances.Add(model, factory);
      }
    }

    /// returns the factory that corresponds to the given model
    protected static UMLFactory getFactory(UMLModel model) {
      UMLFactory instance = null;
      instances.TryGetValue(model, out instance);
      return instance;
    }

    /// returns the singleton instance of the factory
    public static UMLFactory getInstance(UMLModel model) {
      UMLFactory instance = getFactory(model);
      if (instance == null) {
        instance = model.factory;
      }
      return instance;
    }
    /// <summary>
    /// returns the first instance of the factory.
    /// To be used when only one factory exists
    /// </summary>
    /// <returns>the first (and only?) instance of the factory</returns>
    public static UMLFactory getInstance()
    {
    	if (instances.Count > 0)
    	{
    		return instances.Values.ElementAt(0);
    	}else
    	{
    		return null;
    	}
    }

    public UMLModel model { get; set; }

    public UMLFactory(UMLModel model) {
      this.model = model;
      UMLFactory.addFactory(model, this);
    }

    /// creates a new UML element based on the given object to wrap
    public abstract UML.Classes.Kernel.Element createElement
      (Object objectToWrap);<commit_msg>added createValueSpecification<commit_after>﻿using System;
using System.Collections; 
using System.Collections.Generic;
using System.Linq;

using TSF.UmlToolingFramework;

namespace TSF.UmlToolingFramework.UML.Extended {

  public abstract class UMLFactory {
    private static Dictionary<UMLModel, UMLFactory> instances = 
      new Dictionary<UMLModel,UMLFactory>();

    private static void addFactory(UMLModel model, UMLFactory factory) {
      if (!instances.ContainsKey(model)) {
        instances.Add(model, factory);
      }
    }

    /// returns the factory that corresponds to the given model
    protected static UMLFactory getFactory(UMLModel model) {
      UMLFactory instance = null;
      instances.TryGetValue(model, out instance);
      return instance;
    }

    /// returns the singleton instance of the factory
    public static UMLFactory getInstance(UMLModel model) {
      UMLFactory instance = getFactory(model);
      if (instance == null) {
        instance = model.factory;
      }
      return instance;
    }
    /// <summary>
    /// returns the first instance of the factory.
    /// To be used when only one factory exists
    /// </summary>
    /// <returns>the first (and only?) instance of the factory</returns>
    public static UMLFactory getInstance()
    {
    	if (instances.Count > 0)
    	{
    		return instances.Values.ElementAt(0);
    	}else
    	{
    		return null;
    	}
    }

    public UMLModel model { get; set; }

    public UMLFactory(UMLModel model) {
      this.model = model;
      UMLFactory.addFactory(model, this);
    }
    public abstract UML.Classes.Kernel.ValueSpecification createValueSpecification(object objectToWrap);
    /// creates a new UML element based on the given object to wrap
    public abstract UML.Classes.Kernel.Element createElement
      (Object objectToWrap);
{'fraction_non_alphanumeric': 0.08844108592219424, 'fraction_numerical': 0.001119507416736636, 'mean_word_length': 2.8388829215896885, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4657706', 'n_tokens_mistral': 1008, 'n_tokens_neox': 992, 'n_words': 295}