コード例 #1
0
 public override Expression GetExpression(IContainerContext containerContext, TypeInformation typeInfo, ResolutionContext resolutionInfo)
 {
     throw new NotImplementedException();
 }
コード例 #2
0
 public override bool CanUseForResolution(IContainerContext containerContext, TypeInformation typeInfo, ResolutionContext resolutionContext) =>
 typeInfo.Type.GetEnumerableType() != null;
コード例 #3
0
 public bool CanUseForResolution(TypeInformation typeInfo, ResolutionContext resolutionContext) =>
 typeInfo.Type.IsClosedGenericType() &&
 this.supportedTypes.Contains(typeInfo.Type.GetGenericTypeDefinition());
コード例 #4
0
 public static TypeInformation <TOut> GetFlatMapReturnTypes <TIn, TOut>(IFlatMapFunction <TIn, TOut> flatMapInterface,
                                                                        TypeInformation <TIn> inType) => GetFlatMapReturnTypes(flatMapInterface, inType, null, false);
コード例 #5
0
 internal ArrayTypeInformation(int type_index, SymbolLoadedModule module, TypeInformation array_type)
     : base(SymTagEnum.SymTagArrayType, 0, type_index, module, string.Empty)
 {
     ArrayType = array_type;
     Count     = (int)array_type.Size;
 }
コード例 #6
0
 public TypeModel()
 {
     DataModel = new TypeInformation();
 }
コード例 #7
0
        public static TypeInformation[] GetTypes(object com_obj)
        {
            var obj = (IDispatch)com_obj;
            int count;
            obj.GetTypeInfoCount(out count);

            // MSDN says count is 0 or 1 :P
            var ret = new TypeInformation[count];

            for (int i = 0; i < count; i++)
            {
                ITypeInfo typeInfo;
                obj.GetTypeInfo(0, 0, out typeInfo);
                string strName, strDocString, strHelpFile;
                int dwHelpContext;
                typeInfo.GetDocumentation(-1, out strName, out strDocString, out dwHelpContext, out strHelpFile);
                ret[i] = new TypeInformation
                             {
                                 Name = strName,
                                 Documentation = strDocString,
                                 HelpContext = dwHelpContext,
                                 HelpFile = strHelpFile
                             };
            }

            return ret;
        }
コード例 #8
0
 public bool CanUseForResolution(IContainerContext containerContext, TypeInformation typeInfo, ResolutionContext resolutionContext) =>
 containerContext.ContainerConfigurator.ContainerConfiguration.UnknownTypeResolutionEnabled &&
 typeInfo.Type.IsResolvableType();
コード例 #9
0
 public IEnumerable <ServiceRegistration> GetRegistrationsOrDefault(TypeInformation typeInfo, ResolutionContext resolutionContext) =>
 this.GetRegistrationsForType(typeInfo.Type)
 ?.FilterExclusiveOrDefault(typeInfo, resolutionContext, this.enumerableFilters)
 ?.OrderBy(reg => reg.RegistrationOrder);
コード例 #10
0
ファイル: CompilerServices.cs プロジェクト: leloulight/dnx
 public CompilerServices(string name, TypeInformation compiler)
 {
     Name = name;
     ProjectCompiler = compiler;
 }
コード例 #11
0
 public ServiceRegistration GetRegistrationOrDefault(TypeInformation typeInfo, ResolutionContext resolutionContext) =>
 this.GetRegistrationsForType(typeInfo.Type)?.SelectOrDefault(typeInfo, resolutionContext,
                                                              resolutionContext.IsTopRequest ? this.topLevelFilters : this.filters);
コード例 #12
0
 public override bool CanUseForResolution(IContainerContext containerContext, TypeInformation typeInfo, ResolutionInfo resolutionInfo) =>
 containerContext.ContainerConfigurator.ContainerConfiguration.UnknownTypeResolutionEnabled &&
 typeInfo.Type.IsValidForRegistration();
コード例 #13
0
 public static bool HasValue <T>(T value)
 {
     return(TypeInformation <T> .IsValueType || TypeInformation <T> .IsNotNull(value));
 }
コード例 #14
0
 public Expression GetExpression(IResolutionStrategy resolutionStrategy,
                                 TypeInformation typeInfo,
                                 ResolutionContext resolutionInfo)
 {
     return(Expression.Constant(new Test1()));
 }
コード例 #15
0
 public InputFormatSourceFunction(IInputFormat <TOutput, IInputSplit> format, TypeInformation <TOutput> typeInfo)
 {
     _format   = format;
     _typeInfo = typeInfo;
 }
コード例 #16
0
 internal static TypeInformation GetTypeInformation(Type type)
 {
     lock (typeNameCache)
     {
         TypeInformation information = null;
         if (!typeNameCache.TryGetValue(type, out information))
         {
             bool flag;
             string clrAssemblyName = FormatterServices.GetClrAssemblyName(type, out flag);
             information = new TypeInformation(FormatterServices.GetClrTypeFullName(type), clrAssemblyName, flag);
             typeNameCache.Add(type, information);
         }
         return information;
     }
 }
コード例 #17
0
ファイル: ConditionRule.cs プロジェクト: z4kn4fein/stashbox
 public bool ShouldIncrementWeight(TypeInformation typeInformation, ServiceRegistration registration,
     ResolutionContext resolutionContext) =>
     registration.HasCondition && registration.IsUsableForCurrentContext(typeInformation);
コード例 #18
0
 /// <inheritdoc />
 public bool IsUsableForCurrentContext(TypeInformation typeInfo) =>
 this.RegistrationContext.TargetTypeCondition == null && this.RegistrationContext.ResolutionCondition == null && (this.RegistrationContext.AttributeConditions == null || !this.RegistrationContext.AttributeConditions.Any()) ||
 this.RegistrationContext.TargetTypeCondition != null && typeInfo.ParentType != null && this.RegistrationContext.TargetTypeCondition == typeInfo.ParentType ||
 this.RegistrationContext.AttributeConditions != null && typeInfo.CustomAttributes != null &&
 this.RegistrationContext.AttributeConditions.Intersect(typeInfo.CustomAttributes.Select(attribute => attribute.GetType())).Any() ||
 this.RegistrationContext.ResolutionCondition != null && this.RegistrationContext.ResolutionCondition(typeInfo);
コード例 #19
0
ファイル: ConditionRule.cs プロジェクト: z4kn4fein/stashbox
 public bool IsValidForCurrentRequest(TypeInformation typeInformation, ServiceRegistration registration,
     ResolutionContext resolutionContext) => !registration.HasCondition ||
                                             registration.HasCondition && registration.IsUsableForCurrentContext(typeInformation);
コード例 #20
0
 public override Expression GetExpression(IContainerContext containerContext, TypeInformation typeInfo, ResolutionContext resolutionInfo) =>
 Expression.Constant(Substitute.For(new[] { typeInfo.Type }, new object[] { }));
コード例 #21
0
 public override bool CanUseForResolution(IContainerContext containerContext, TypeInformation typeInfo, ResolutionInfo resolutionInfo) =>
 typeInfo.Type.IsClosedGenericType() && this.supportedTypes.Contains(typeInfo.Type.GetGenericTypeDefinition());
コード例 #22
0
 public override bool CanUseForResolution(IContainerContext containerContext, TypeInformation typeInfo, ResolutionInfo resolutionInfo) =>
 containerContext.ContainerConfigurator.ContainerConfiguration.OptionalAndDefaultValueInjectionEnabled &&
 (typeInfo.HasDefaultValue || typeInfo.Type.GetTypeInfo().IsValueType || typeInfo.Type == typeof(string) || typeInfo.IsMember);
コード例 #23
0
ファイル: EdiWriter.cs プロジェクト: JelleHissink/EDI.Net
        internal static void WriteValue(EdiWriter writer, PrimitiveTypeCode typeCode, object value, Picture?picture, string format)
        {
            switch (typeCode)
            {
            case PrimitiveTypeCode.Char:
                writer.WriteValue((char)value);
                break;

            case PrimitiveTypeCode.CharNullable:
                writer.WriteValue((value == null) ? (char?)null : (char)value);
                break;

            case PrimitiveTypeCode.Boolean:
                writer.WriteValue((bool)value);
                break;

            case PrimitiveTypeCode.BooleanNullable:
                writer.WriteValue((value == null) ? (bool?)null : (bool)value);
                break;

            case PrimitiveTypeCode.SByte:
                writer.WriteValue((sbyte)value, picture);
                break;

            case PrimitiveTypeCode.SByteNullable:
                writer.WriteValue((value == null) ? (sbyte?)null : (sbyte)value, picture);
                break;

            case PrimitiveTypeCode.Int16:
                writer.WriteValue((short)value, picture);
                break;

            case PrimitiveTypeCode.Int16Nullable:
                writer.WriteValue((value == null) ? (short?)null : (short)value, picture);
                break;

            case PrimitiveTypeCode.UInt16:
                writer.WriteValue((ushort)value, picture);
                break;

            case PrimitiveTypeCode.UInt16Nullable:
                writer.WriteValue((value == null) ? (ushort?)null : (ushort)value, picture);
                break;

            case PrimitiveTypeCode.Int32:
                writer.WriteValue((int)value, picture);
                break;

            case PrimitiveTypeCode.Int32Nullable:
                writer.WriteValue((value == null) ? (int?)null : (int)value, picture);
                break;

            case PrimitiveTypeCode.Byte:
                writer.WriteValue((byte)value, picture);
                break;

            case PrimitiveTypeCode.ByteNullable:
                writer.WriteValue((value == null) ? (byte?)null : (byte)value, picture);
                break;

            case PrimitiveTypeCode.UInt32:
                writer.WriteValue((uint)value, picture);
                break;

            case PrimitiveTypeCode.UInt32Nullable:
                writer.WriteValue((value == null) ? (uint?)null : (uint)value);
                break;

            case PrimitiveTypeCode.Int64:
                writer.WriteValue((long)value, picture);
                break;

            case PrimitiveTypeCode.Int64Nullable:
                writer.WriteValue((value == null) ? (long?)null : (long)value, picture);
                break;

            case PrimitiveTypeCode.UInt64:
                writer.WriteValue((ulong)value, picture);
                break;

            case PrimitiveTypeCode.UInt64Nullable:
                writer.WriteValue((value == null) ? (ulong?)null : (ulong)value, picture);
                break;

            case PrimitiveTypeCode.Single:
                writer.WriteValue((float)value, picture);
                break;

            case PrimitiveTypeCode.SingleNullable:
                writer.WriteValue((value == null) ? (float?)null : (float)value);
                break;

            case PrimitiveTypeCode.Double:
                writer.WriteValue((double)value, picture);
                break;

            case PrimitiveTypeCode.DoubleNullable:
                writer.WriteValue((value == null) ? (double?)null : (double)value, picture);
                break;

            case PrimitiveTypeCode.DateTime:
                writer.WriteValue((DateTime)value, format);
                break;

            case PrimitiveTypeCode.DateTimeNullable:
                writer.WriteValue((value == null) ? (DateTime?)null : (DateTime)value, format);
                break;

            case PrimitiveTypeCode.DateTimeOffset:
                writer.WriteValue((DateTimeOffset)value, format);
                break;

            case PrimitiveTypeCode.DateTimeOffsetNullable:
                writer.WriteValue((value == null) ? (DateTimeOffset?)null : (DateTimeOffset)value, format);
                break;

            case PrimitiveTypeCode.Decimal:
                writer.WriteValue((decimal)value, picture);
                break;

            case PrimitiveTypeCode.DecimalNullable:
                writer.WriteValue((value == null) ? (decimal?)null : (decimal)value, picture);
                break;

            case PrimitiveTypeCode.Guid:
                writer.WriteValue((Guid)value);
                break;

            case PrimitiveTypeCode.GuidNullable:
                writer.WriteValue((value == null) ? (Guid?)null : (Guid)value);
                break;

            case PrimitiveTypeCode.TimeSpan:
                writer.WriteValue((TimeSpan)value);
                break;

            case PrimitiveTypeCode.TimeSpanNullable:
                writer.WriteValue((value == null) ? (TimeSpan?)null : (TimeSpan)value);
                break;

#if !PORTABLE
            case PrimitiveTypeCode.BigInteger:
                // this will call to WriteValue(object)
                writer.WriteValue((BigInteger)value);
                break;

            case PrimitiveTypeCode.BigIntegerNullable:
                // this will call to WriteValue(object)
                writer.WriteValue((value == null) ? (BigInteger?)null : (BigInteger)value);
                break;
#endif
            case PrimitiveTypeCode.Uri:
                writer.WriteValue((Uri)value);
                break;

            case PrimitiveTypeCode.String:
                writer.WriteValue((string)value, picture);
                break;

            case PrimitiveTypeCode.Bytes:
                writer.WriteValue((byte[])value);
                break;

#if !(PORTABLE || DOTNET)
            case PrimitiveTypeCode.DBNull:
                writer.WriteNull();
                break;
#endif
            default:
#if !PORTABLE
                if (value is IConvertible)
                {
                    // the value is a non-standard IConvertible
                    // convert to the underlying value and retry
                    IConvertible convertable = (IConvertible)value;

                    TypeInformation typeInformation = ConvertUtils.GetTypeInformation(convertable);

                    // if convertable has an underlying typecode of Object then attempt to convert it to a string
                    PrimitiveTypeCode resolvedTypeCode = (typeInformation.TypeCode == PrimitiveTypeCode.Object) ? PrimitiveTypeCode.String : typeInformation.TypeCode;
                    Type resolvedType = (typeInformation.TypeCode == PrimitiveTypeCode.Object) ? typeof(string) : typeInformation.Type;

                    object convertedValue = convertable.ToType(resolvedType, CultureInfo.InvariantCulture);

                    WriteValue(writer, resolvedTypeCode, convertedValue, picture, format);
                    break;
                }
                else
#endif
                {
                    WriteValue(writer, PrimitiveTypeCode.String, $"{value}", picture, format);
                    break;
                    // consider throwing some times...
                    //throw CreateUnsupportedTypeException(writer, value);
                }
            }
        }
コード例 #24
0
        /// <exception cref="InvalidOperationException">If instance cannot be created.</exception>
        private object Create(TypeInformation information)
        {
            Dictionary <ConstructorInfo, List <ConstructorParameter> > constructors = new Dictionary <ConstructorInfo, List <ConstructorParameter> >();

            ConstructorInfo[] publicConstructors = information.InstanceType.GetConstructors();
            if (publicConstructors.Length == 0)
            {
                throw new InvalidOperationException(information.InstanceType.FullName + " do not have any public constructors.");
            }

            foreach (var constructor in publicConstructors)
            {
                constructors.Add(constructor, new List <ConstructorParameter>());
                foreach (var parameter in constructor.GetParameters())
                {
                    ConstructorParameter constructorParameter = new ConstructorParameter {
                        Parameter = parameter
                    };
                    constructors[constructor].Add(constructorParameter);

                    TypeInformation typeInfo;
                    lock (_instances)
                        if (!_instances.TryGetValue(parameter.ParameterType, out typeInfo))
                        {
                            continue;
                        }                                         // this constructor wont work, but check what parameters we are missing.

                    try
                    {
                        constructorParameter.Instance = typeInfo.Instance ?? Create(typeInfo);
                    }
                    catch (InvalidOperationException err)
                    {
                        throw new InvalidOperationException(
                                  "Failed to create '" + typeInfo.InterfaceType.FullName + "' that '" + information.InterfaceType +
                                  "' is dependent off. Check inner exception for more details.", err);
                    }
                }

                // check if all parameters was found.
                bool allFound = true;
                foreach (var parameter in constructors[constructor])
                {
                    if (parameter.Instance != null)
                    {
                        continue;
                    }
                    allFound = false;
                    break;
                }

                if (!allFound)
                {
                    continue;
                }

                // now create instance.
                information.ConstructorArguments = new object[constructors[constructor].Count];
                int index = 0;
                foreach (var parameter in constructors[constructor])
                {
                    information.ConstructorArguments[index++] = parameter.Instance;
                }
                return(Activator.CreateInstance(information.InstanceType, information.ConstructorArguments));
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Failed to create '" + information.InstanceType.FullName + "', due to missing constructorparamters.");
            foreach (var pair in constructors)
            {
                sb.Append(pair.Key + " are missing: ");
                foreach (var parameter in pair.Value)
                {
                    if (parameter.Instance == null)
                    {
                        sb.Append(parameter.Parameter.Name + ", ");
                    }
                }
                sb.Length -= 2;
                sb.AppendLine();
            }
            throw new InvalidOperationException(sb.ToString());
        }
コード例 #25
0
 /// <inheritdoc />
 public bool IsUsableForCurrentContext(TypeInformation typeInfo) =>
 !this.HasCondition ||
 this.HasParentTypeConditionAndMatch(typeInfo) ||
 this.HasAttributeConditionAndMatch(typeInfo) ||
 this.HasResolutionConditionAndMatch(typeInfo);
コード例 #26
0
 public static TypeInformation <TKey> GetKeySelectorTypes <TElement, TKey>(Functions.IKeySelector <TElement, TKey> keySelector, TypeInformation <TElement> type)
 {
     throw new NotImplementedException();
 }
コード例 #27
0
 private bool HasParentTypeConditionAndMatch(TypeInformation typeInfo) =>
 this.RegistrationContext.TargetTypeCondition != null && typeInfo.ParentType != null && this.RegistrationContext.TargetTypeCondition == typeInfo.ParentType;
コード例 #28
0
 public override bool CanUseForResolution(IContainerContext containerContext, TypeInformation typeInfo, ResolutionContext resolutionInfo) =>
 !this.requestedTypes.Contains(typeInfo.Type) && typeInfo.Type.CanMock();
コード例 #29
0
 private bool HasAttributeConditionAndMatch(TypeInformation typeInfo) =>
 this.RegistrationContext.AttributeConditions != null && typeInfo.CustomAttributes != null &&
 this.RegistrationContext.AttributeConditions.Intersect(typeInfo.CustomAttributes.Select(attribute => attribute.GetType())).Any();
コード例 #30
0
 public bool CanUseForResolution(TypeInformation typeInfo, ResolutionContext resolutionInfo)
 {
     return(typeInfo.Type == typeof(ITest1));
 }
コード例 #31
0
 private bool HasResolutionConditionAndMatch(TypeInformation typeInfo) =>
 this.RegistrationContext.ResolutionCondition != null && this.RegistrationContext.ResolutionCondition(typeInfo);
コード例 #32
0
 internal static TypeInformation GetTypeInformation(Type type)
 { 
     lock (typeNameCache)
     {
         TypeInformation typeInformation = null;
         if (!typeNameCache.TryGetValue(type, out typeInformation)) 
         {
             typeInformation = new TypeInformation(FormatterServices.GetClrTypeFullName(type), FormatterServices.GetClrAssemblyName(type)); 
             typeNameCache.Add(type, typeInformation); 
         }
         return typeInformation; 
     }
 }
コード例 #33
0
        public VoxelInfo[, ,] ApplyRule(VoxelInfo[, ,] neighbourhood)
        {
            // Apply each 18-th turn
            if (neighbourhood[1, 1, 1].Ticks < TypeInformation.GetGrowingSteps(VoxelType.TEAK_WOOD))
            {
                return(null);
            }

            int height = random.Next((int)(TypeInformation.GetGrowHeight(VoxelType.TEAK_WOOD) * 0.75), (int)(TypeInformation.GetGrowHeight(VoxelType.TEAK_WOOD) * 1.25));

            VoxelInfo[, ,] output = new VoxelInfo[3, 3, 3];
            int gen = neighbourhood[1, 1, 1].Generation;

            if (gen == 0)
            {
                // Grow a 2x2 quad (override current generation)
                output[1, 1, 1] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1);
                output[2, 1, 1] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1);
                output[1, 1, 2] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1);
                output[2, 1, 2] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1);

                if (TypeInformation.IsNotWoodButBiomass(neighbourhood[1, 0, 1].Type) || neighbourhood[1, 0, 1].Type == VoxelType.EMPTY)
                {
                    output[1, 0, 1] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1, 0, 0, Direction.UP);
                }
                if (TypeInformation.IsNotWoodButBiomass(neighbourhood[2, 0, 1].Type) || neighbourhood[2, 0, 1].Type == VoxelType.EMPTY)
                {
                    output[2, 0, 1] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1, 0, 0, Direction.UP);
                }
                if (TypeInformation.IsNotWoodButBiomass(neighbourhood[1, 0, 2].Type) || neighbourhood[1, 0, 2].Type == VoxelType.EMPTY)
                {
                    output[1, 0, 2] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1, 0, 0, Direction.UP);
                }
                if (TypeInformation.IsNotWoodButBiomass(neighbourhood[2, 0, 2].Type) || neighbourhood[2, 0, 2].Type == VoxelType.EMPTY)
                {
                    output[2, 0, 2] = new VoxelInfo(VoxelType.TEAK_WOOD, true, 1, 0, 0, Direction.UP);
                }
            }
            else if (gen < height)
            {
                Int3 coord = DirectionConverter.FromDirection(DirectionConverter.ToOppositeDirection(neighbourhood[1, 1, 1].From));
                // Grow in given direction
                if (TypeInformation.IsNotWoodButBiomass(neighbourhood[coord.X, coord.Y, coord.Z].Type) || neighbourhood[coord.X, coord.Y, coord.Z].Type == VoxelType.EMPTY)
                {
                    output[coord.X, coord.Y, coord.Z] = new VoxelInfo(VoxelType.TEAK_WOOD, true, gen + 1, 0, 0, neighbourhood[1, 1, 1].From);
                }
                output[1, 1, 1] = new VoxelInfo(VoxelType.TEAK_WOOD);
            }
            else
            {
                if (neighbourhood[1, 1, 1].From == Direction.DOWN)
                {
                    if (TypeInformation.IsNotWoodButBiomass(neighbourhood[1, 2, 1].Type) || neighbourhood[1, 2, 1].Type == VoxelType.EMPTY)
                    {
                        output[1, 2, 1] = new VoxelInfo(VoxelType.TEAK_LEAF, true, 1);
                    }
                }
                output[1, 1, 1] = new VoxelInfo(VoxelType.TEAK_WOOD);
            }
            return(output);
        }
コード例 #34
0
ファイル: binaryformatter.cs プロジェクト: ItsVeryWindy/mono
 internal static TypeInformation GetTypeInformation(Type type)
 {
     lock (typeNameCache)
     {
         TypeInformation typeInformation = null;
         if (!typeNameCache.TryGetValue(type, out typeInformation))
         {
             bool hasTypeForwardedFrom;
             string assemblyName = FormatterServices.GetClrAssemblyName(type, out hasTypeForwardedFrom);
             typeInformation = new TypeInformation(FormatterServices.GetClrTypeFullName(type), assemblyName, hasTypeForwardedFrom);
             typeNameCache.Add(type, typeInformation);
         }
         return typeInformation;
     }
 }
コード例 #35
0
 public Expression GetExpression(IContainerContext containerContext, TypeInformation typeInfo, ResolutionContext resolutionContext)
 {
     containerContext.Container.Register(typeInfo.Type,
                                         containerContext.ContainerConfigurator.ContainerConfiguration.UnknownTypeConfigurator);
     return(containerContext.ResolutionStrategy.BuildResolutionExpression(containerContext, resolutionContext, typeInfo));
 }