internal static string GetMappedTypeName(MappedType type) { switch (type) { case MappedType.Int32: return "int"; case MappedType.Int64: return "long"; case MappedType.UInt32: return "uint"; case MappedType.UInt64: return "ulong"; case MappedType.Single: return "float"; case MappedType.Double: return "double"; case MappedType.Boolean: return "bool"; case MappedType.String: return "string"; case MappedType.ByteString: return "pb::ByteString"; case MappedType.Enum: return null; case MappedType.Message: return null; default: throw new ArgumentOutOfRangeException("Unknown mapped type " + type); } }
/// <summary> /// Converts the given array type into a corresponding LLVM type. /// </summary> /// <param name="type">The array type to convert.</param> /// <returns>The mapped LLVM type.</returns> public MappedType GetArrayType(Type type) { if (type == null) { throw new ArgumentNullException(nameof(type)); } if (!type.IsArray) { throw CompilationContext.GetArgumentException( ErrorMessages.WrongArrayType, type); } if (!type.GetElementType().IsValueType) { throw CompilationContext.GetNotSupportedException( ErrorMessages.NotSupportedArrayElementType, type); } if (!typeMapping.TryGetValue(type, out MappedType result)) { var arrayType = StructCreateNamed(LLVMContext, GetLLVMName(type.ToString(), "Array")); StructSetBody( arrayType, PointerType(GetType(type.GetElementType())), LLVMContext.Int32Type); result = new MappedType(type, arrayType, 2, null); typeMapping.Add(type, result); } return(result); }
public MappedType Find(string name, Func <MappedType, string> predicate) { var split = name.Split('.').SelectMany(x => x.Split('+')).ToArray(); if (split.Length > 1) { MappedType type = null; foreach (var s in split) { if (type == null) { type = Find(s, predicate); } else { type = type.Nested.SingleOrDefault(x => predicate(x) == s); } } return(type); } return(Types.SingleOrDefault(x => predicate(x) == name)); }
/// <summary> /// Returns the default value for a mapped type. /// </summary> private static object GetDefaultValueForMappedType(MappedType type) { switch (type) { case MappedType.Int32: return(0); case MappedType.Int64: return((long)0); case MappedType.UInt32: return((uint)0); case MappedType.UInt64: return((ulong)0); case MappedType.Single: return((float)0); case MappedType.Double: return((double)0); case MappedType.Boolean: return(false); case MappedType.String: return(""); case MappedType.ByteString: return(ByteString.Empty); case MappedType.Message: return(null); case MappedType.Enum: return(null); default: throw new ArgumentException("Invalid type specified"); } }
public MappedType Find(string name, Func <MappedType, string> predicate) { var split = name.Split('.', '+', '/').ToArray(); if (split.Length > 1) { MappedType type = null; var current = new StringBuilder(); foreach (var s in split) { current.Append(s); if (type == null) { type = Find(s, predicate); } else { type = type.Nested.SingleOrDefault(x => predicate(x) == current.ToString()); } current.Append('/'); } return(type); } return(Types.SingleOrDefault(x => predicate(x) == name)); }
internal static string GetMappedTypeName(MappedType type) { switch (type) { case MappedType.Int32: return("int"); case MappedType.Int64: return("long"); case MappedType.UInt32: return("uint"); case MappedType.UInt64: return("ulong"); case MappedType.Single: return("float"); case MappedType.Double: return("double"); case MappedType.Boolean: return("bool"); case MappedType.String: return("string"); case MappedType.ByteString: return("pb::ByteString"); case MappedType.Enum: return(null); case MappedType.Message: return(null); default: throw new ArgumentOutOfRangeException("Unknown mapped type " + type); } }
public static JSObject CreateCSOwnedProxy(IntPtr jsHandle, MappedType mappedType, int shouldAddInflight) { JSObject?jsObject = null; lock (_csOwnedObjects) { if (!_csOwnedObjects.TryGetValue((int)jsHandle, out WeakReference <JSObject>?reference) || !reference.TryGetTarget(out jsObject) || jsObject.IsDisposed) { jsObject = mappedType switch { MappedType.JSObject => new JSObject(jsHandle), MappedType.Array => new Array(jsHandle), MappedType.ArrayBuffer => new ArrayBuffer(jsHandle), MappedType.DataView => new DataView(jsHandle), MappedType.Function => new Function(jsHandle), MappedType.Uint8Array => new Uint8Array(jsHandle), _ => throw new ArgumentOutOfRangeException(nameof(mappedType)) }; _csOwnedObjects[(int)jsHandle] = new WeakReference <JSObject>(jsObject, trackResurrection: true); } } if (shouldAddInflight != 0) { jsObject.AddInFlight(); } return(jsObject); }
public void Compile(Mappings result, ModuleDefinition module) { foreach (var typeDefinition in module.GetAllTypes()) { var type = new MappedType(typeDefinition.FullName, GetOrDefault(typeDefinition.Name)); foreach (var methodDefinition in typeDefinition.Methods) { if (methodDefinition.Name.IsObfuscated() && !Names.ContainsKey(methodDefinition.Name)) { continue; // dead method } var method = new MappedMethod(methodDefinition, GetOrDefault(methodDefinition.Name)); foreach (var parameterDefinition in methodDefinition.Parameters) { method.Parameters.Add(GetOrDefault(parameterDefinition.Name) ?? parameterDefinition.Name); } if (!methodDefinition.Name.IsObfuscated() && !method.Parameters.Any()) { continue; } type.Methods.Add(method); } foreach (var fieldDefinition in typeDefinition.Fields) { var field = new MappedMember(fieldDefinition.Name, GetOrDefault(fieldDefinition.Name) ?? fieldDefinition.Name.Clean()); if (!fieldDefinition.Name.IsObfuscated() && fieldDefinition.Name == field.Mapped) { continue; } type.Fields.Add(field); } foreach (var propertyDefinition in typeDefinition.Properties) { var field = new MappedMember(propertyDefinition.Name, GetOrDefault(propertyDefinition.Name)); if (!propertyDefinition.Name.IsObfuscated()) { continue; } type.Properties.Add(field); } if (!typeDefinition.Name.IsObfuscated() && !type.Fields.Any() && !type.Methods.Any() && !type.Properties.Any() && !type.Nested.Any()) { continue; } result.Types.Add(type); } }
public static AbstractXmlSerializable FromXmlString(string xmlDoc) { MappedType t = MappedType.UNDEFINED; XDocument serialized = XDocument.Parse(xmlDoc); XElement typeElement = serialized.Root.Element("Type"); if (typeElement == null) { return(null); } string type = typeElement.Value; if (ModelXmlMapper.map.TryGetValue(type, out t)) { switch (t) { case MappedType.MESSAGE: MessageModel msg = new MessageModel(); msg.FromXml(serialized.Root); return(msg); case MappedType.USER: UserModel user = new UserModel(); user.FromXml(serialized.Root); return(user); case MappedType.CONTACT: Contact contact = new Contact(); contact.FromXml(serialized.Root); return(contact); case MappedType.CHAT_REQUEST: ChatRequest req = new ChatRequest(); req.FromXml(serialized.Root); return(req); case MappedType.CHAT_REQUEST_RESPONSE: ChatRequestResponse resp = new ChatRequestResponse(); resp.FromXml(serialized.Root); return(resp); case MappedType.LOGIN: Login login = new Login(); login.FromXml(serialized.Root); return(login); case MappedType.LOGIN_RESPONSE: LoginResponse loginResp = new LoginResponse(); loginResp.FromXml(serialized.Root); return(loginResp); case MappedType.UNDEFINED: throw new Exception("Don't know how to parse this type"); } } return(null); }
private static string GetTypeMartenAlias(MappedType documentType) { return(documentType.Alias ?? documentType.Type.GetTypeName() .Replace(".", "_") .SplitCamelCase() .Replace(" ", "_") .ToLowerInvariant()); }
public void RegisterProcessUnit(string Context, IPipedProcessUnit unit) { OperatorAuthentication.AuthedAction(Context, () => { FileInfo fi = new FileInfo(Assembly.GetAssembly(unit.GetType()).FullName); processUnits.Add(MappedType.CreateFrom(unit)); Trace.WriteLine(Language.Query("LWMS.Pipeline.Register.R", "Registered R Unit: {0}", unit.GetType().ToString())); }, false, true, PermissionID.RTRegisterRProcessUnit, PermissionID.RuntimeAll); }
internal FieldDescriptor(FieldDescriptorProto proto, FileDescriptor file, MessageDescriptor parent, int index, bool isExtension) : base(proto, file, ComputeFullName(file, parent, proto.Name), index) { if (proto.HasType) { fieldType = GetFieldTypeFromProtoType(proto.Type); mappedType = FieldTypeToMappedTypeMap[fieldType]; } if (FieldNumber <= 0) { throw new DescriptorValidationException(this, "Field numbers must be positive integers."); } if (isExtension) { if (!proto.HasExtendee) { throw new DescriptorValidationException(this, "FieldDescriptorProto.Extendee not set for extension field."); } containingType = null; // Will be filled in when cross-linking if (parent != null) { extensionScope = parent; } else { extensionScope = null; } } else { if (proto.HasExtendee) { throw new DescriptorValidationException(this, "FieldDescriptorProto.Extendee set for non-extension field."); } containingType = parent; if (proto.HasOneofIndex) { if (proto.OneofIndex < 0 || proto.OneofIndex >= parent.Proto.OneofDeclCount) { throw new DescriptorValidationException(this, "FieldDescriptorProto.oneof_index is out of range for type " + parent.Name); } containingOneof = parent.Oneofs[proto.OneofIndex]; containingOneof.fieldCount++; } extensionScope = null; } file.DescriptorPool.AddSymbol(this); }
private void MapCollections <T>(MappedType mappedType, IPropertyContainerMapper <T> classMapper) where T : class { if (!mappedType.Collections.Any()) { return; } new CollectionMapper <T>(classMapper, mappedType.Collections).Map(); }
private void MapPrimitives <T>(MappedType mappedType, IMinimalPlainPropertyContainerMapper <T> classMapper) where T : class { if (!mappedType.Primitives.Any()) { return; } new PrimitiveMapper <T>(classMapper, mappedType.Primitives).Map(); }
private void MapReferences <T>(MappedType mappedType, IPropertyContainerMapper <T> classMapper) where T : class { if (!mappedType.References.Any()) { return; } new ReferenceMapper <T>(classMapper, mappedType.References).Map(); }
public void SaveTo(XmlTextWriter xw) { xw.WriteAttributeString("type", MappedType.ToString()); xw.WriteAttributeString("source", Source.ToString()); xw.WriteAttributeString("uuid", UUID.ToString()); if (Source == SourceType.RawInput) { xw.WriteAttributeString("vid", VendorID.ToString("X")); xw.WriteAttributeString("pid", ProductID.ToString("X")); xw.WriteAttributeString("rpt_hash", ReportHash.ToString()); xw.WriteAttributeString("idx", DeviceIndex.ToString()); } else if (Source == SourceType.XInput) { xw.WriteAttributeString("idx", DeviceIndex.ToString()); } else if (Source == SourceType.MUNIA) { xw.WriteAttributeString("devicepath", DevicePath); } else if (Source == SourceType.Arduino) { xw.WriteAttributeString("arduino_port", ArduinoPort.Name); xw.WriteAttributeString("arduino_type", ArduinoSource.ToString()); } xw.WriteStartElement("buttons"); foreach (var btn in ButtonMaps) { btn.SaveTo(xw); } xw.WriteEndElement(); xw.WriteStartElement("axes"); foreach (var axis in AxisMaps) { axis.SaveTo(xw); } xw.WriteEndElement(); xw.WriteStartElement("buttons_to_axis"); foreach (var btn in ButtonToAxisMaps) { btn.SaveTo(xw); } xw.WriteEndElement(); xw.WriteStartElement("axis_to_buttons"); foreach (var axis in AxisToButtonMaps) { axis.SaveTo(xw); } xw.WriteEndElement(); }
static void ApplyType(List <MappedType> types, MappedType newType) { var type = types.SingleOrDefault(x => newType.Equals(x)); if (type == null) { types.Add(newType); } else { type.Mapped = newType.Mapped; void ApplyMembers(List <MappedMember> members, List <MappedMember> newMembers) { foreach (var newMember in newMembers) { var member = members.SingleOrDefault(x => newMember.Equals(x, false)); if (member == null) { members.Add(newMember); } else { member.Mapped = newMember.Mapped; member.Original = newMember.Original; } } } ApplyMembers(type.Fields, newType.Fields); ApplyMembers(type.Properties, newType.Properties); foreach (var newMember in newType.Methods) { var member = type.Methods.SingleOrDefault(x => newMember.Equals(x, false)); if (member == null) { type.Methods.Add(newMember); } else { member.Mapped = newMember.Mapped; member.Original = newMember.Original; member.Parameters = newMember.Parameters; } } foreach (var nestedType in newType.Nested) { ApplyType(type.Nested, nestedType); } } }
private object GetValueCore(IClass @class, bool other) { if (@class == null) { return(null); } var systemType = MappedType.FromType(@class).SystemType; var defaultImplementation = systemType.GetCustomAttributes(typeof(DefaultImplementationTypeAttribute), false); return(Activator.CreateInstance((defaultImplementation[0] as DefaultImplementationTypeAttribute).DefaultImplementationType)); }
public void Register(Type to, MappedType mappedType, ResolutionMap resolutionMap) { if(activators.ContainsKey(to)) return; var generator = new TypeGenerator.TypeGenerator(); var candidates = mappedType.Candidates; int candidateCount = candidates.Count; for (int candidateCounter = 0; candidateCounter < candidateCount; candidateCounter++) { var candidate = candidates[candidateCounter]; if (activators.ContainsKey(candidate.Type)) continue; var activatorType = generator.CreateType(context => { context.Named(Guid.NewGuid() + "Builder"); context.InheritFrom<SiegeActivator>(); context.OverrideMethod<SiegeActivator>(activator => activator.Instantiate(null), method => method.WithBody(body => { var instance = body.CreateVariable(to); var array = body.CreateArray(typeof(object)); array.AssignFromParameter(new MethodParameter(0)); var items = new List<ILocalIndexer>(); var parameters = candidate.Parameters; var parameterCount = parameters.Count; for (int i = 0; i < parameterCount; i++) { var info = parameters[i]; var arg1 = array.LoadValueAtIndex(info.ParameterType, body, info.Position); items.Add(arg1); } var constructorArgs = new Type[candidate.Parameters.Count]; var candidateParameters = candidate.Parameters; var candidateParameterCount = candidateParameters.Count; for (int i = 0; i < candidateParameterCount; i++) { var arg = candidateParameters[i]; constructorArgs[arg.Position] = arg.ParameterType; } instance.AssignFrom(body.Instantiate(to, constructorArgs, items.OfType<ILocalIndexer, ILocalIndexer>())); body.Return(instance); })); }); var constructor = activatorType.GetConstructor(new Type[] { }); activators.Add(candidate.Type, (SiegeActivator)constructor.Invoke(new object[] { })); } }
public ExtensionDescriptorLite(string fullName, IEnumLiteMap enumTypeMap, int number, FieldType type, object defaultValue, bool isRepeated, bool isPacked) { this.fullName = fullName; this.enumTypeMap = enumTypeMap; this.number = number; this.type = type; this.mapType = FieldMappingAttribute.MappedTypeFromFieldType(type); this.isRepeated = isRepeated; this.isPacked = isPacked; this.defaultValue = defaultValue; }
public void CanExecuteMappedProcedureAsync() { MappedType mappedType = null; Assert.DoesNotThrowAsync(async() => { mappedType = await procedureMapper.ExecuteMappedProcedureAsync <MappedType>(ProcedureName, new DbParameter[] { }); }, "The mapping operation must be successful"); Assert.IsNotNull(mappedType, "The mapping result must be a non-null value"); }
public void Init(params MappedType[] units) { if (units.Length == 0) { FileInfo fi = new FileInfo(Assembly.GetAssembly(typeof(DefaultProcessUnit)).FullName); _processUnits.Add(MappedType.CreateFrom(new DefaultProcessUnit())); } else { _processUnits = new List <MappedType>(units); } }
private void btnAdd_Click(object sender, EventArgs e) { try { var property = cboProperties.SelectedItem as Property; var mappedType = cboItemTypes.SelectedItem as MappedType; if (mappedType == null) { var itemType = cboItemTypes.SelectedItem as ItemType; if (itemType != null) { mappedType = new MappedType(itemType) { Level = 1 }; } } if (mappedType != null && property != null && (property == _emptyProperty || !string.IsNullOrEmpty(txtValue.Text))) { if (mappedType.Level == 0) { mappedType.Level = 1; foreach (var m in _mappings) { m.Type.Level++; } } var mapping = new DataMapping() { IsCalculated = chkCalculated.Checked, Type = mappedType, Property = (property == _emptyProperty ? null : property), Value = txtValue.Text }; if (!_mappings.Any(m => m.Type == mappedType)) { cboItemTypes.DataSource = GetItemTypeList(mappedType); cboItemTypes.SelectedItem = mapping.Type; } AddMapping(mapping); ResetMapping(); xsltEditor.Text = BuildXslt(); } } catch (Exception ex) { Utils.HandleError(ex); } }
public PipelineData Process(PipelineData Input) { { HttpListenerRoutedContext context = Input.PrimaryData as HttpListenerRoutedContext; if (requests is null) { requests = ApplicationConfiguration.Current.GetValueArray("RoutedRequests"); } if (RouteTargets == null) { var targets = ApplicationConfiguration.Current.GetValueArray("RouteTargets"); RouteTargets = new List <MappedType>(); //Initialize the targets. foreach (var item in targets) { var parted = item.Split(','); FileInfo fi = new(parted[0]); var asm = DomainManager.LoadFromFile(context.PipelineAuth, fi.FullName); var t = asm.GetType(parted[1]); MappedType mappedType = MappedType.CreateFrom(t); RouteTargets.Add(mappedType); } } else if (RouteTargets.Count is 0) { var targets = ApplicationConfiguration.Current.GetValueArray("RouteTargets"); foreach (var item in targets) { var parted = item.Split(','); FileInfo fi = new(parted[0]); var asm = DomainManager.LoadFromFile(context.PipelineAuth, fi.FullName); var t = asm.GetType(parted[1]); MappedType mappedType = MappedType.CreateFrom(t); RouteTargets.Add(mappedType); } } var path0 = context.Request.Url.LocalPath.Substring(1); //Dispose the first '/' if (path0 is not "") //Ignore when the path is empty to prevent potential problems when performing matching. { for (int i = 0; i < requests.Length; i++) { if (path0.ToUpper().StartsWith(requests[i].ToUpper()))//Ignore case { (Input.SecondaryData as HttpPipelineArguments).isHandled = (RouteTargets[i].TargetObject as IHttpEventHandler).Handle(context, requests[i]); return(Input); } } } } return(Input); }
public IConformistHoldersProvider Map <T>(MappedType mappedType, IClassMapper <T> classMapper) where T : class { MapKey(mappedType.Key, classMapper); MapVersion(mappedType.Version, classMapper); MapPrimitives(mappedType, classMapper); MapReferences(mappedType, classMapper); MapCollections(mappedType, classMapper); return((IConformistHoldersProvider)classMapper); }
private static string GetTypeMartenAlias(MappedType documentType) { var typeName = documentType.Type.Name; if (documentType.Type.GetTypeInfo().IsGenericType) { typeName = documentType.Type.GetPrettyName(); } return(documentType.Alias ?? (documentType.Type.IsNested ? $"{documentType.Type.DeclaringType.Name}.{typeName}" : typeName) .Replace(".", "_") .SplitCamelCase() .Replace(" ", "_") .ToLowerInvariant()); }
/// <summary> /// Converts the given fixed-buffer struct into a corresponding LLVM type. /// </summary> /// <param name="fba">The fixed-buffer attribute.</param> /// <param name="type">The type to convert.</param> /// <returns>The mapped LLVM type.</returns> private LLVMTypeRef GetFixedBufferType(FixedBufferAttribute fba, Type type) { Debug.Assert(fba != null, "Invalid fixed-buffer attribute"); Debug.Assert(type != null, "Invalid type"); if (!typeMapping.TryGetValue(type, out MappedType mappedType)) { var elementType = GetType(fba.ElementType); var llvmType = ArrayType(elementType, fba.Length); var fieldOffsets = new Dictionary <FieldInfo, int> { [type.GetFields()[0]] = 0 }; mappedType = new MappedType(type, llvmType, fba.Length, fieldOffsets); typeMapping.Add(type, mappedType); } return(mappedType.LLVMType); }
private LLVMValueRef GetObjectValue(MappedType type, object instanceValue) { if (instanceValue == null) { return(ConstNull(type.LLVMType)); } var instanceType = type.ManagedType; var hasSupportedBase = instanceType.HasSupportedBaseClass(); var elements = new LLVMValueRef[type.NumLLVMTypeElements]; // Fill all elements will zero var elementTypes = GetStructElementTypes(type.LLVMType); for (int i = 0, e = elements.Length; i < e; ++i) { elements[i] = ConstNull(elementTypes[i]); } // Fill with real values foreach (var field in type.Fields) { var fieldValue = field.Key.GetValue(instanceValue); var llvmFieldValue = GetValue(field.Key.FieldType, fieldValue); elements[field.Value] = llvmFieldValue; } if (hasSupportedBase) { // We have to handle the base-class fields var baseClassValue = Convert.ChangeType(instanceValue, instanceType.BaseType); var mappedBaseType = GetStructType(instanceType.BaseType); var llvmBaseClassValue = GetObjectValue(mappedBaseType, baseClassValue); elements[0] = llvmBaseClassValue; } if (elements.Length < 1) { return(ConstNamedStruct(type.LLVMType, out LLVMValueRef _, 0)); } return(ConstNamedStruct(type.LLVMType, out elements[0], elements.Length)); }
/// <summary> /// Register and initialize a specified module. /// </summary> /// <param name="item"></param> /// <returns></returns> public static bool Register(string AuthContext, string item) { bool __ = false; try { OperatorAuthentication.AuthedAction(AuthContext, () => { try { var asm = Assembly.LoadFrom(item); FileInfo fi = new(item); var TPS = asm.GetTypes(); foreach (var TP in TPS) { if (typeof(IManageCommand).IsAssignableFrom(TP)) { var MC = (IManageCommand)Activator.CreateInstance(TP); Trace.WriteLine(Language.Query("LWMS.Commands.Found", "Found Manage Command:{0},{1}", MC.CommandName, TP.ToString())); ManageCommands.Add(MC.CommandName, MappedType.CreateFrom(MC)); var alias = MC.Alias; foreach (var MCA in alias) { ManageCommandAliases.Add(MCA, MappedType.CreateFrom(MC)); } } } __ = true; } catch (Exception) { Trace.Write(Language.Query("LWMS.Commands.Error.LoadModule", "Cannot load management module: {0}", item)); } }, false, true, PermissionID.RegisterCmdModule, PermissionID.CmdModuleAll); } catch (Exception) { Trace.Write(Language.Query("LWMS.Commands.Error.LoadModule", "Cannot load management module: {0}", item)); } return(__); }
void DoConvert() { var managed = new List <MapEntry> (); foreach (var kvp in managedToJava) { string managedName = kvp.Key; MappedType javaType = kvp.Value; managed.Add( new MapEntry( new MapManagedType(managedName) { IsDuplicate = javaType.DuplicateCount > 0 }, new MapJavaType(javaType.TargetType) ) ); } var java = new List <MapEntry> (); foreach (var kvp in javaToManaged) { string javaName = kvp.Key; MappedType managedType = kvp.Value; java.Add( new MapEntry( new MapManagedType(managedType.TargetType) { IsDuplicate = managedType.DuplicateCount > 0 }, new MapJavaType(javaName) ) ); } map = MakeMap(managed, java); }
private object GetValueCore(PrimitiveType type, bool other) { var systemType = MappedType.FromType(type).SystemType; if (systemType == typeof(bool)) { return(other); } if (systemType == typeof(Uri)) { return(other ? new Uri("foo://bar") : new Uri("bar://foo")); } if (other) { return(Convert.ChangeType(42, systemType)); } else { return(Convert.ChangeType(23, systemType)); } }
private IList GetItemTypeList(MappedType mappedType = null) { if (_mappings.Any() || mappedType != null) { var mappings = _mappings.Select(m => m.Type).Distinct(); if (mappedType != null) { mappings = mappings.Concat(Enumerable.Repeat(mappedType, 1)); } var itemTypes = mappings.OrderBy(m => m.Level).ToList(); itemTypes.InsertRange(0, _cache.GetParents(itemTypes.First().ItemType).Select(i => new MappedType(i)).OrderBy(m => m.ItemType.ToString())); itemTypes.AddRange(GetUiChildren(itemTypes.Last().ItemType).Select(i => new MappedType(i) { Level = itemTypes.Last().Level + 1 }).OrderBy(m => m.ItemType.ToString())); return(itemTypes); } else { return(_cache.ItemTypes.OrderBy(i => i.ToString()).ToList()); } }
public FieldMappingAttribute(MappedType mappedType, WireFormat.WireType wireType) { MappedType = mappedType; WireType = wireType; }
private IList GetItemTypeList(MappedType mappedType = null) { if (_mappings.Any() || mappedType != null) { var mappings = _mappings.Select(m => m.Type).Distinct(); if (mappedType != null) mappings = mappings.Concat(Enumerable.Repeat(mappedType, 1)); var itemTypes = mappings.OrderBy(m => m.Level).ToList(); itemTypes.InsertRange(0, _cache.GetParents(itemTypes.First().ItemType).Select(i => new MappedType(i)).OrderBy(m => m.ItemType.ToString())); itemTypes.AddRange(GetUiChildren(itemTypes.Last().ItemType).Select(i => new MappedType(i) { Level = itemTypes.Last().Level + 1 }).OrderBy(m => m.ItemType.ToString())); return itemTypes; } else { return _cache.ItemTypes.OrderBy(i => i.ToString()).ToList(); } }
public virtual void Register(Type to, MappedType mappedType, ResolutionMap resolutionMap) { }
/// <summary> /// Register a mapping between a tag and a type. /// </summary> /// <param name="tag">The tag.</param> /// <param name="type">The type.</param> /// <param name="alias"></param> public virtual void RegisterTagMapping(string tag, Type type, bool alias) { if (tag == null) throw new ArgumentNullException("tag"); if (type == null) throw new ArgumentNullException("type"); // Prefix all tags by ! tag = Uri.EscapeUriString(tag); if (tag.StartsWith("tag:")) { // shorten tag // TODO this is not really failsafe var shortTag = "!!" + tag.Substring(tag.LastIndexOf(':') + 1); // Auto register tag to schema schema.RegisterTag(shortTag, tag); tag = shortTag; } tag = tag.StartsWith("!") ? tag : "!" + tag; lock (lockCache) { tagToType[tag] = new MappedType(type, alias); // Only register types that are not aliases if (!alias) typeToTag[type] = tag; } }