private string GetGenericArgumentListText(ITypeCollection value, bool instance)
        {
            using (StringWriter writer = new StringWriter(CultureInfo.InvariantCulture))
            {
                if (value.Count > 0)
                {
                    writer.Write("<");

                    for (int i = 0; i < value.Count; i++)
                    {
                        if (i != 0)
                        {
                            writer.Write(",");
                        }

                        if (instance)
                        {
                            writer.Write(this.GetTypeText(value[i]));
                        }
                    }

                    writer.Write(">");
                }

                return(writer.ToString());
            }
        }
예제 #2
0
        public string GetName(IMethodReference value)
        {
            ITypeCollection genericArguments = value.GenericArguments;

            if (genericArguments.Count > 0)
            {
                using (StringWriter writer = new StringWriter(CultureInfo.InvariantCulture)) {
                    for (int i = 0; i < genericArguments.Count; i++)
                    {
                        if (i != 0)
                        {
                            writer.Write(", ");
                        }
                        IType type = genericArguments[i];
                        if (type != null)
                        {
                            writer.Write(type.ToString());
                        }
                        else
                        {
                            writer.Write("???");
                        }
                    }
                    return(value.Name + "<" + writer.ToString() + ">");
                }
            }
            return(value.Name);
        }
예제 #3
0
 public NewTypeViewModel(Authentication authentication, ITypeCategory category, ITypeTemplate template)
     : base(authentication, template, true)
 {
     this.Category       = category;
     this.typeCollection = category.GetService(typeof(ITypeCollection)) as ITypeCollection;
     this.DisplayName    = Resources.Title_NewType;
 }
예제 #4
0
        public string GetName(ITypeReference value)
        {
            if (value == null)
            {
                throw new NotSupportedException();
            }
            ITypeCollection genericArguments = value.GenericArguments;

            if (genericArguments.Count > 0)
            {
                using (StringWriter writer = new StringWriter(CultureInfo.InvariantCulture)) {
                    for (int i = 0; i < genericArguments.Count; i++)
                    {
                        if (i != 0)
                        {
                            writer.Write(",");
                        }
                        IType iType = genericArguments[i];
                        if (iType != null)
                        {
                            this.TypeWriter(writer, iType);
                        }
                    }
                    return(value.Name + "<" + writer.ToString() + ">");
                }
            }
            return(value.Name);
        }
예제 #5
0
 public virtual void VisitTypeCollection(ITypeCollection value)
 {
     for (int i = 0; i < value.Count; i++)
     {
         VisitType(value[i]);
     }
 }
예제 #6
0
        private IType[] GetFilterTypes(ITypeCollection types, string typeNames)
        {
            var query = from item in types
                        where item.Name.GlobMany(typeNames) || item.Path.GlobMany(typeNames)
                        select item;

            return(query.Distinct().ToArray());
        }
예제 #7
0
 public override void Dispose()
 {
     try
     {
         lock (this.SyncObject)
         {
             if (this.metadata != null)
             {
                 this.metadata.Dispose();
                 this.metadata = null;
             }
             if (this.constraints != null)
             {
                 this.constraints.Clear();
                 this.constraints = null;
             }
             if (this._constraints != null)
             {
                 this._constraints.Dispose();
                 this._constraints = null;
             }
             if (this.constructors != null)
             {
                 this.constructors.Dispose();
                 this.constructors = null;
             }
             if (this.events != null)
             {
                 this.events.Dispose();
                 this.events = null;
             }
             if (this.indexers != null)
             {
                 this.indexers.Dispose();
                 this.indexers = null;
             }
             if (this.methods != null)
             {
                 this.methods.Dispose();
                 this.methods = null;
             }
             if (this.properties != null)
             {
                 this.properties.Dispose();
                 this.properties = null;
             }
             if (this._members != null)
             {
                 this._members.Dispose();
                 this._members = null;
             }
         }
     }
     finally
     {
         base.Dispose();
     }
 }
예제 #8
0
 private void ClearCachedTypes()
 {
     _assignableTypes             = null;
     _derivedTypes                = null;
     _directDerivedTypes          = null;
     _interfaces                  = null;
     _mostDerivedParentInterfaces = null;
     _leastDerivedChildInterfaces = null;
     _constructedTypes            = null;
 }
        public static async Task <IType> GenerateTypeAsync(this ITypeCollection typeCollection, Authentication authentication)
        {
            if (typeCollection.GetService(typeof(ITypeCategoryCollection)) is ITypeCategoryCollection typeCategoryCollection)
            {
                var category = await typeCategoryCollection.GetRandomTypeCategoryAsync();

                return(await category.GenerateTypeAsync(authentication));
            }
            throw new NotImplementedException();
        }
 /// <summary>
 /// Obtains a <see cref="IMethodPointerReferenceExpression"/>
 /// with the <paramref name="signature"/> provided.
 /// </summary>
 /// <param name="signature">The <see cref="ITypeCollection"/>
 /// relative to the type-signature of the <see cref="IMethodPointerReferenceExpression"/>
 /// to obtain.</param>
 /// <returns>A new <see cref="IMethodPointerReferenceExpression"/>
 /// relative to the <paramref name="signature"/>
 /// provided.</returns>
 public IMethodPointerReferenceExpression GetPointer(ITypeCollection signature)
 {
     if (signature == null)
     {
         return(this.GetPointerReference());
     }
     else
     {
         return(this.GetPointerReference(signature));
     }
 }
        public static async Task <IType[]> GenerateTypesAsync(this ITypeCollection typeCollection, Authentication authentication, int count)
        {
            var itemList = new List <IType>(count);

            for (var i = 0; i < count; i++)
            {
                var item = await typeCollection.GenerateTypeAsync(authentication);

                itemList.Add(item);
            }
            return(itemList.ToArray());
        }
 public static Task <IType[]> GetRandomTypesAsync(this ITypeCollection typeCollection, TypeFlags typeFlags, Func <IType, bool> predicate)
 {
     return(typeCollection.Dispatcher.InvokeAsync(() =>
     {
         var query = from item in typeCollection
                     where TypeFlagsUtility.Test(item, typeFlags) == true && predicate(item) == true
                     let i = RandomUtility.Next <int>()
                             orderby i
                             select item;
         return query.ToArray();
     }));
 }
예제 #13
0
 private CopyTypeViewModel(Authentication authentication, IType type)
 {
     this.authentication = authentication;
     this.type           = type;
     this.type.Dispatcher.VerifyAccess();
     this.types         = type.GetService(typeof(ITypeCollection)) as ITypeCollection;
     this.categories    = type.GetService(typeof(ITypeCategoryCollection)) as ITypeCategoryCollection;
     this.categoryPaths = this.categories.Select(item => item.Path).ToArray();
     this.categoryPath  = this.type.Category.Path;
     this.typeName      = type.Name;
     this.NewName       = type.Name;
     this.DisplayName   = Resources.Title_CopyType;
 }
        /// <summary>
        /// Create a mapping context.
        /// </summary>
        /// <param name="types">Set of types</param>
        /// <param name="fieldSource">Where to look for fields on a node</param>
        /// <param name="typeIgnorePattern">Optional regex pattern for types to ignore</param>
        /// <param name="nodeCommentProvider">Optional provider for node comments</param>
        /// <param name="logger">Optional logger</param>
        /// <returns>Newly created context</returns>
        public static Context Create(
            ITypeCollection types,
            FieldSource fieldSource,
            Regex typeIgnorePattern = null,
            INodeCommentProvider nodeCommentProvider = null,
            ILogger logger = null)
        {
            if (types == null)
            {
                throw new ArgumentNullException(nameof(types));
            }

            return(new Context(types, fieldSource, typeIgnorePattern, nodeCommentProvider, logger));
        }
 public static void ClassInit(TestContext context)
 {
     app = new CremaBootstrapper();
     app.Initialize(context, nameof(ITypeCollection_DispatcherTest));
     cremaHost = app.GetService(typeof(ICremaHost)) as ICremaHost;
     cremaHost.Dispatcher.Invoke(() =>
     {
         authentication = cremaHost.Start();
         dataBase       = cremaHost.DataBases.Random();
         dataBase.Load(authentication);
         dataBase.Enter(authentication);
         dataBase.TypeContext.AddRandomItems(authentication);
         types = dataBase.TypeContext.Types;
     });
 }
        internal Context(
            ITypeCollection types,
            FieldSource fieldSource,
            Regex typeIgnorePattern = null,
            INodeCommentProvider nodeCommentProvider = null,
            ILogger logger = null)
        {
            if (types == null)
            {
                throw new ArgumentNullException(nameof(types));
            }

            this.Types               = types;
            this.FieldSource         = fieldSource;
            this.TypeIgnorePattern   = typeIgnorePattern;
            this.NodeCommentProvider = nodeCommentProvider;
            this.Logger              = logger;
        }
예제 #17
0
 /// <summary>
 /// Creates a new <see cref="GenericParameterData"/> with the
 /// <paramref name="name"/>, <paramref name="requiresBlankConstructor"/>, <paramref name="constructors"/>,
 /// <paramref name="methods"/>, <paramref name="indexers"/>, <paramref name="properties"/> and <paramref name="events"/> provided.
 /// </summary>
 /// <param name="name">The <see cref="String"/> value of the unique identifier of the <see cref="IGenericParameter"/>
 /// to create.</param>
 /// <param name="constructors">The <see cref="SignaturesData"/> associated to the constructors to add.</param>
 /// <param name="methods">The <see cref="ExtendedSignaturesData"/> associated to the methods to add.</param>
 /// <param name="indexers">The <see cref="ExtendedSignaturesData"/> associated to the indexers to add.</param>
 /// <param name="properties">The <see cref="TypedNameSeries"/> associated to the properties to add.</param>
 /// <param name="events">The <see cref="TypedNameSeries"/> associated to the events to add.</param>
 /// <param name="constraints">The <see cref="IType"/> array
 /// specifying the constraints which bind the resultant generic
 /// parameter.</param>
 public GenericParameterData(string name, SignaturesData constructors, ExtendedSignaturesData methods, ExtendedSignaturesData indexers, TypedNameSeries properties, TypedNameSeries events, IType[] constraints = null)
 {
     this.name              = name;
     this.methods           = methods;
     this.indexers          = indexers;
     this.properties        = properties;
     this.events            = events;
     this.ctors             = constructors;
     this.specialConstraint = GenericTypeParameterSpecialConstraint.None;
     if (constraints == null)
     {
         this.constraints = null;
     }
     else
     {
         this.constraints = constraints.ToCollection();
     }
 }
예제 #18
0
 public static IType RandomSample(this ITypeCollection types)
 {
     return(types.Random(item =>
     {
         if (item.IsPrivate == true)
         {
             return false;
         }
         if (item.IsLocked == true)
         {
             return false;
         }
         if (item.Category.Parent == null)
         {
             return false;
         }
         return true;
     }));
 }
예제 #19
0
        public GenericInstance(IType type, IEnumerable <IType> args)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            _args = new TypeList(args);

            if (_args.Count != type.GenericParameters.Count)
            {
                throw new InvalidOperationException();
            }

            Type = type;
        }
 public static Task <IType[]> GetRandomTypesAsync(this ITypeCollection typeCollection, Func <IType, bool> predicate)
 {
     return(GetRandomTypesAsync(typeCollection, TypeFlags.None, predicate));
 }
 public static Task <IType> GetRandomTypeAsync(this ITypeCollection typeCollection, TypeFlags typeFlags, Func <IType, bool> predicate)
 {
     return(typeCollection.Dispatcher.InvokeAsync(() => typeCollection.RandomOrDefault(item => TypeFlagsUtility.Test(item, typeFlags) == true && predicate(item) == true)));
 }
 public static Task <IType> GetRandomTypeAsync(this ITypeCollection typeCollection, Func <IType, bool> predicate)
 {
     return(typeCollection.Dispatcher.InvokeAsync(() => typeCollection.RandomOrDefault(predicate)));
 }
 public static Task <IType> GetRandomTypeAsync(this ITypeCollection typeCollection)
 {
     return(GetRandomTypeAsync(typeCollection, DefaultPredicate));
 }
예제 #24
0
 public virtual void VisitTypeCollection(ITypeCollection value)
 {
     for (int i = 0; i < value.Count; i++)
     {
         this.VisitType(value[i]);
     }
 }
예제 #25
0
 public static bool Compare(this ITypeCollection source, ITypeCollection n)
 {
     return Compare<IType>(source,n);
 }
            private void WriteGenericArgumentList(ITypeCollection parameters, IFormatter formatter)
            {
                if (parameters.Count > 0)
                {
                    formatter.Write("<");
                    for (int i = 0; i < parameters.Count; i++)
                    {
                        if (i != 0)
                        {
                            formatter.Write("; ");
                        }

                        this.WriteType(parameters[i], formatter);
                    }

                    formatter.Write(">");
                }
            }
예제 #27
0
 public IMethodPointerReferenceExpression GetMethodPointer(string name, ITypeCollection signature, ITypeCollection genericParameters)
 {
     return(this.GetMethod(name, genericParameters).GetPointer(signature));
 }
예제 #28
0
 public static bool Compare(this ITypeCollection source, ITypeCollection n, Func<IType, IType, Action<string, string>, bool> checkitem, Action<string, string> errAct)
 {
     return Compare<IType>(source,n,checkitem,errAct);
 }
 public static Task <IType[]> GetRandomTypesAsync(this ITypeCollection typeCollection, TypeFlags typeFlags)
 {
     return(GetRandomTypesAsync(typeCollection, typeFlags, DefaultPredicate));
 }
 /// <summary>
 /// Obtains a <see cref="IConstructorPointerReferenceExpression"/>
 /// with the <paramref name="signature"/> provided.
 /// </summary>
 /// <param name="signature">The <see cref="ITypeCollection"/>
 /// relative to the type-signature of the <see cref="IMethodPointerReferenceExpression"/>
 /// to obtain.</param>
 /// <returns>A new <see cref="IConstructorPointerReferenceExpression"/>
 /// relative to the <paramref name="signature"/>
 /// provided.</returns>
 public IConstructorPointerReferenceExpression GetPointer(ITypeCollection signature)
 {
     return(new ConstructorPointerReferenceExpression(this, signature));
 }
 private void InsituTransformTypeCollection(ITypeCollection value)
 {
     // for (int i = 0; i < value.Count; i++)
     {
         // value[i] = this.TransformType(value[i]);
     }
 }
        private string GetGenericArgumentListText(ITypeCollection value, bool instance)
        {
            using (StringWriter writer = new StringWriter(CultureInfo.InvariantCulture))
            {
                if (value.Count > 0)
                {
                    writer.Write("<");

                    for (int i = 0; i < value.Count; i++)
                    {
                        if (i != 0)
                        {
                            writer.Write(",");
                        }

                        if (instance)
                        {
                            writer.Write(this.GetTypeText(value[i]));
                        }
                    }

                    writer.Write(">");
                }

                return writer.ToString();
            }
        }
예제 #33
0
 public QueryProcessor(IQueryTypeCollection typeCollection, IServiceProvider serviceProvider)
 {
     _typeCollection  = typeCollection;
     _serviceProvider = serviceProvider;
 }
예제 #34
0
 public IMethodReferenceStub GetMethod(string name, ITypeCollection genericParameters)
 {
     return(new UnboundMethodReferenceStub(this, name, genericParameters));
 }
 protected virtual MethodPointerReferenceExpression GetPointerReference(ITypeCollection signature)
 {
     return(new MethodPointerReferenceExpression(this, signature));
 }
예제 #36
0
 public static bool Compare(this ITypeCollection source, ITypeCollection n, Func<IType, IType, bool> checkitem)
 {
     return Compare<IType>(source,n,checkitem);
 }
 public TypeDataConverter(ITypeCollection types, JsonConverter <TypeRef> simpleConv)
 {
     this.types      = types;
     this.simpleConv = simpleConv;
 }
        public virtual ITypeCollection TransformTypeCollection(ITypeCollection types)
        {
            IType[] array = new IType[types.Count];
            for (int i = 0; i < types.Count; i++)
            {
                array[i] = this.TransformType(types[i]);
            }

            ITypeCollection target = new TypeCollection();
            target.AddRange(array);
            return target;
        }