Exemple #1
0
        public bool TryClone(PropModelType propModel, out PropModelType clonedCopy)
        {
            if (!ReferenceEquals(propModel.PropModelCache, this))
            {
                throw new InvalidOperationException("We are being asked to clone a PropModel that is assocated with some other PropModel cache.");
            }

            propModel.PropModelCache = null;
            clonedCopy = (PropModelType)propModel.CloneIt();
            Add(clonedCopy);
            return(true);
        }
Exemple #2
0
        // Make a copy and if a new class name is given, start a new family of Type definitions.
        public PropModelType Open(PropModelType propModel, string fullClassName, out long generationId)
        {
            if (!propModel.IsFixed)
            {
                if (fullClassName == null)
                {
                    System.Diagnostics.Debug.WriteLine("Already Open.");
                    generationId = propModel.GenerationId;
                    return(propModel);
                }
                else
                {
                    throw new InvalidOperationException($"Cannot open the PropModel with FullClassName: {this}; it is already open.");
                }
            }
            else
            {
                propModel.PropModelCache = null;
                PropModelType result = (PropModelType)propModel.CloneIt();
                result.Open();

                if (fullClassName != null)
                {
                    string ns = GetNamespace(fullClassName, out string className);

                    if (ns != null)
                    {
                        result.NamespaceName = ns;
                    }

                    result.ClassName = className;
                }

                generationId = Add(result);
                return(result);
            }
        }