public override string GetValueTypeName (ITypeResolutionService typeResolver) { if (value == null) return null; else return value.GetType ().AssemblyQualifiedName; }
internal ResXResourceReader(string fileName, ITypeResolutionService typeResolver, IAliasResolver aliasResolver) { this.fileName = fileName; this.typeResolver = typeResolver; this.aliasResolver = aliasResolver; if(this.aliasResolver == null) { this.aliasResolver = new ReaderAliasResolver(); } }
public override void BeginLoad(IDesignerLoaderHost host) { this.loading = true; this.typeResolutionService = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService)); this.designerLoaderHost = host; base.BeginLoad(host); }
//TODO: Some way to reset this when host is reset public WebFormReferenceManager (DesignerHost host) { if (host == null) throw new ArgumentNullException ("host"); this.host = host; this.typeRes = host.GetService (typeof (ITypeResolutionService)) as ITypeResolutionService; if (typeRes == null) throw new Exception ("Could not obtain ITypesResolutionService from host"); }
public override string GetValueTypeName (ITypeResolutionService typeResolver) { Type type = ResolveType (typeString, typeResolver); if (type == null) return typeString; else return type.AssemblyQualifiedName; }
internal ResXResourceReader(Stream stream, ITypeResolutionService typeResolver, IAliasResolver aliasResolver) { this.stream = stream; this.typeResolver = typeResolver; this.aliasResolver = aliasResolver; if (this.aliasResolver == null) { this.aliasResolver = new ReaderAliasResolver(); } }
public override string GetValueTypeName (ITypeResolutionService typeResolver) { // although params ignored by GetValue. .NET resolves the type for GetValueTypeName Type type = ResolveType (resXFileRef.TypeName, typeResolver); if (type == null) return resXFileRef.TypeName; else return type.AssemblyQualifiedName; }
string InternalGetValueType (ITypeResolutionService typeResolver) { object retrievedObject; try { retrievedObject = DeserializeObject (typeResolver); } catch { return typeof (object).AssemblyQualifiedName; } if (retrievedObject == null) return null; else return retrievedObject.GetType ().AssemblyQualifiedName; }
public override object GetValue (ITypeResolutionService typeResolver) { if (!String.IsNullOrEmpty(mime_type) && mime_type != ResXResourceWriter.ByteArraySerializedObjectMimeType) return null; Type type = ResolveType (typeString, typeResolver); if (type == null) throw new TypeLoadException(); TypeConverter c = TypeDescriptor.GetConverter (type); if (c == null) throw new TypeLoadException(); return ConvertData (c); }
public NemerleContainedLanguage(IVsTextBufferCoordinator bufferCoordinator, NemerleIntellisenseProvider intellisenseProject, uint itemId, IVsHierarchy pHierarchy) { if (null == bufferCoordinator) { throw new ArgumentNullException("bufferCoordinator"); } if (null == intellisenseProject) { throw new ArgumentNullException("intellisenseProject"); } _hierarchy = pHierarchy; object projectItem = null; pHierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_ExtObject, out projectItem); _projectItem = projectItem as EnvDTE.ProjectItem; EnvDTE.Property prop = _projectItem.Properties.Item("FullPath"); if (prop != null) _filePath = prop.Value as string; var project = _projectItem.ContainingProject as NemerleOAProject; if(project != null) { _projectInfo = ((NemerleProjectNode)project.Project).ProjectInfo; } _typeResolutionService = null; DynamicTypeService typeService = LanguageService.GetService(typeof(DynamicTypeService)) as DynamicTypeService; if (typeService != null) _typeResolutionService = typeService.GetTypeResolutionService(this._hierarchy); this.bufferCoordinator = bufferCoordinator; this.intellisenseProject = intellisenseProject; this.itemId = itemId; // Make sure that the secondary buffer uses the IronPython language service. IVsTextLines buffer; ErrorHandler.ThrowOnFailure(bufferCoordinator.GetSecondaryBuffer(out buffer)); Guid languageGuid; this.GetLanguageServiceID(out languageGuid); ErrorHandler.ThrowOnFailure(buffer.SetLanguageServiceID(ref languageGuid)); _documentClosingEventHandler = new _dispDocumentEvents_DocumentClosingEventHandler(OnDocumentClosing); }
public void Compile() { List<BooFileNode> localCompileList; bool recompileAll; lock (compileList) { if (typeResolverContext == null) { typeResolverContext = GlobalServices.TypeService.GetContextTypeResolver(projectManager); typeResolver = GlobalServices.TypeService.GetTypeResolutionService(projectManager); } localCompileList = new List<BooFileNode>(compileList); compileList.Clear(); if (localCompileList.Count == 0 && !referencesDirty) return; recompileAll = referencesDirty; referencesDirty = false; } var results = new Dictionary<BooFileNode, CompileResults>(); foreach (var file in BooProjectNode.GetFileEnumerator(projectManager)) if (recompileAll || localCompileList.Contains(file)) { // this seemingly redundant variable ensures that each closure below has its own copy of // the file reference. Without it they share the same copy decalred in the loop statemenet // essentially all of them will point to the last element in the loop var localfile = file; results.Add(file, new CompileResults(() => localfile.Url, localfile.GetCompilerInput, ()=>GlobalServices.LanguageService.GetLanguagePreferences().TabSize)); } else results.Add(file, file.GetCompileResults()); Boo.ASTMapper.CompilerManager.Compile( GlobalServices.LanguageService.GetLanguagePreferences().TabSize, references.Values.Select(ae => ae.GetAssembly(typeResolver.GetAssembly)).Where(a => a != null), results.Values); foreach (var result in results) result.Key.SetCompilerResults(result.Value); }
internal ResXResourceReader(TextReader reader, ITypeResolutionService typeResolver, IAliasResolver aliasResolver) { this.reader = reader; this.typeResolver = typeResolver; this.aliasResolver = aliasResolver; if(this.aliasResolver == null) { this.aliasResolver = new ReaderAliasResolver(); } }
public string GetValueTypeName(ITypeResolutionService typeResolver) { return(type.AssemblyQualifiedName); }
private ResXResourceReader(ITypeResolutionService typeResolver) { this.typeResolver = typeResolver; this.aliasResolver = new ReaderAliasResolver(); }
public ResXResourceReader(Stream stream, ITypeResolutionService typeResolver) : this(stream, typeResolver, (IAliasResolver)null) { }
object DeserializeObject (ITypeResolutionService typeResolver) { try { if (mime_type == ResXResourceWriter.SoapSerializedObjectMimeType) { //FIXME: theres a test in the suite to check that a type converter converts from invariant string //do i need to take the string culture into consideration here? SoapFormatter soapF = new SoapFormatter (); if (binder == null) binder = new CustomBinder (typeResolver); soapF.Binder = binder; byte [] data = Convert.FromBase64String (dataString); using (MemoryStream s = new MemoryStream (data)) { return soapF.Deserialize (s); } } else if (mime_type == ResXResourceWriter.BinSerializedObjectMimeType) { BinaryFormatter binF = new BinaryFormatter (); if (binder == null) binder = new CustomBinder (typeResolver); binF.Binder = binder; byte [] data = Convert.FromBase64String (dataString); using (MemoryStream s = new MemoryStream (data)) { return binF.Deserialize (s); } } else // invalid mime_type return null; } catch (SerializationException ex) { if (ex.Message.StartsWith ("Couldn't find assembly")) throw new ArgumentException (ex.Message); else throw ex; } }
protected virtual Type GetType(IDesignerHost host, System.Reflection.AssemblyName assemblyName, string typeName, bool reference) { ITypeResolutionService service = null; Type type = null; if (typeName == null) { throw new ArgumentNullException("typeName"); } if (host != null) { service = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService)); } if (service != null) { if (reference) { if (assemblyName != null) { service.ReferenceAssembly(assemblyName); return(service.GetType(typeName)); } type = service.GetType(typeName); if (type == null) { type = Type.GetType(typeName); } if (type != null) { service.ReferenceAssembly(type.Assembly.GetName()); } return(type); } if (assemblyName != null) { Assembly assembly = service.GetAssembly(assemblyName); if (assembly != null) { type = assembly.GetType(typeName); } } if (type == null) { type = service.GetType(typeName); } return(type); } if (!string.IsNullOrEmpty(typeName)) { if (assemblyName != null) { Assembly assembly2 = null; try { assembly2 = Assembly.Load(assemblyName); } catch (FileNotFoundException) { } catch (BadImageFormatException) { } catch (IOException) { } if (((assembly2 == null) && (assemblyName.CodeBase != null)) && (assemblyName.CodeBase.Length > 0)) { try { assembly2 = Assembly.LoadFrom(assemblyName.CodeBase); } catch (FileNotFoundException) { } catch (BadImageFormatException) { } catch (IOException) { } } if (assembly2 != null) { type = assembly2.GetType(typeName); } } if (type == null) { type = Type.GetType(typeName, false); } } return(type); }
IDictionary LoadProviders(ITypeResolutionService resolution) { if (Configuration.Arguments == null) { return(new System.Collections.Specialized.HybridDictionary(0)); } try { // At most we will have a provider for each argument. IDictionary providers = new System.Collections.Specialized.HybridDictionary(Configuration.Arguments.Length); monitoredArguments = new System.Collections.Specialized.HybridDictionary(Configuration.Arguments.Length); bool hasmonitors = false; IValueInfoService mdservice = GetService <IValueInfoService>(true); // Setup monitoring for dependent argument changes. foreach (Config.Argument argument in Configuration.Arguments) { if (argument.ValueProvider != null) { IValueProvider provider = GetInstance <IValueProvider>(resolution, argument.ValueProvider.Type); // Initialize the provider by passing the configuration for the argument it provides values to. provider.Initialize(mdservice.GetInfo(argument.Name)); if (provider is IAttributesConfigurable) { Configure((IAttributesConfigurable)provider, argument.ValueProvider.AnyAttr); } providers.Add(argument.Name, provider); // Site the provider so it can access all services. if (provider is IComponent) { Add((IComponent)provider); } // Add to the argument-indexed list of providers monitoring arguments. if (argument.ValueProvider.MonitorArgument != null) { hasmonitors = true; foreach (Config.MonitorArgument monitored in argument.ValueProvider.MonitorArgument) { // Throw if the value provider is monitoring the same argument it's attached to. if (monitored.Name == argument.Name) { throw new System.Configuration.ConfigurationException(String.Format( System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.Recipe_ArgumentCantMonitorItself, argument.ValueProvider.Type, argument.Name)); } ArrayList monitoringproviders = (ArrayList)monitoredArguments[monitored.Name]; if (monitoringproviders == null) { monitoringproviders = new ArrayList(); monitoredArguments[monitored.Name] = monitoringproviders; } monitoringproviders.Add(provider); } } } } if (providers.Count != 0 && hasmonitors) { // Attach to change event if monitoring arguments. IComponentChangeService changes = GetService <IComponentChangeService>(true); changes.ComponentChanged += new ComponentChangedEventHandler(OnArgumentChanged); } return(providers); } catch (Exception ex) { throw new ValueProviderException(this.Configuration.Name, Properties.Resources.Recipe_ValueProviderLoadFailed, ex); } }
private T GetInstance <T>(ITypeResolutionService resolution, string concreteType) { ReflectionHelper.EnsureAssignableTo(resolution.GetType(concreteType, true), typeof(T)); return((T)Activator.CreateInstance(resolution.GetType(concreteType, true))); }
public ValueInfo GetInfo(string name) { Configuration.Argument arg = this.CurrentRecipe.ArgumentsByName[name]; if (arg == null) { return(null); } // We need to cache the ArgumentMetaData, otherwise the Wizard validation for repeated arguments will fail if (!metaData.ContainsKey(arg)) { ITypeResolutionService typeResolutionService = (ITypeResolutionService)GetService(typeof(ITypeResolutionService)); Type argType = null; if (typeResolutionService != null) { argType = typeResolutionService.GetType(arg.Type); } else { argType = Type.GetType(arg.Type); } TypeConverter converter = null; if (arg.Converter != null) { Type converterType = null; if (typeResolutionService != null) { converterType = typeResolutionService.GetType(arg.Converter.Type); } else { converterType = Type.GetType(arg.Converter.Type); } if (converterType != null) { converter = (TypeConverter)Activator.CreateInstance(converterType); } } if (converter == null && argType != null) { TypeConverter cinstance = TypeDescriptor.GetConverter(argType); if (argType.IsEnum) { converter = new EnumerationConverter(argType); } else if (argType.IsCOMObject || Attribute.GetCustomAttribute(argType, typeof(ComImportAttribute), true) != null) { converter = new ComObjectConverter(argType); } else if (cinstance != null && cinstance.GetType() != typeof(ComponentConverter)) { // Only use converters that are not the generic ComponentConverter. converter = cinstance; } } ValueInfo argumentMetaData = new ValueInfo( arg.Name, arg.Required, argType, converter); metaData[arg] = argumentMetaData; } return((ValueInfo)metaData[arg]); }
/// <summary> /// Executes the recipe, processing the configuration received at construction time. /// </summary> /// <param name="allowSuspend">Specifies whether the recipe can be suspended.</param> /// <remarks> /// Only when the recipe is executed completely (that is, it's not suspended or cancelled), the /// return value will be <see langword="true"/>. /// </remarks> /// <returns>Whether the recipe finished executing succesfully.</returns> public ExecutionResult Execute(bool allowSuspend) { ITypeResolutionService resolution = GetService <ITypeResolutionService>(true); IDictionaryService arguments = GetService <IDictionaryService>(true); IDictionaryService readonlyargs = new ReadOnlyDictionaryService(arguments); IDictionary providers = LoadProviders(resolution); // Setup custom action execution service if specified. if (Configuration.Actions != null) { if (!String.IsNullOrEmpty(Configuration.Actions.ExecutionServiceType)) { AddService(typeof(IActionExecutionService), GetInstance <IActionExecutionService>(resolution, Configuration.Actions.ExecutionServiceType)); } // Setup custom action coordinator service if specified. if (!String.IsNullOrEmpty(Configuration.Actions.CoordinatorServiceType)) { AddService(typeof(IActionCoordinationService), GetInstance <IActionCoordinationService>(resolution, Configuration.Actions.CoordinatorServiceType)); } } try { CallProviders(providers, readonlyargs, arguments, true); ThrowIfValueTypeArgumentIsOptionalNotNullable(); IConfigurationService configservice = GetService <IConfigurationService>(true); object wizardconfig = configservice.CurrentGatheringServiceData; // Check if we have null values. ThrowIfValueTypeArgumentIsOptionalNotNullable(); RecipeGatheringServiceData gatheringConfig = (RecipeGatheringServiceData)wizardconfig; // Collect if we have both a wizard and a gathering strategy. if (wizardconfig != null) { IValueGatheringService gathering = GetValueGatheringService(resolution, gatheringConfig); if (gathering == null) { throw new RecipeExecutionException(this.Configuration.Name, Properties.Resources.Recipe_ArgumentGatheringRequired); } ExecutionResult result = gathering.Execute(gatheringConfig.Any, allowSuspend); if (result == ExecutionResult.Suspend && !allowSuspend) { throw new InvalidOperationException(Properties.Resources.Recipe_CantSuspendRecipe); } if (result == ExecutionResult.Finish) { CallProviders(providers, readonlyargs, arguments, false); ThrowIfRequiredArgumentsAreNull(arguments); ExecuteActions(readonlyargs, arguments, resolution); } return(result); } else { CallProviders(providers, readonlyargs, arguments, false); ThrowIfRequiredArgumentsAreNull(arguments); ExecuteActions(readonlyargs, arguments, resolution); return(ExecutionResult.Finish); } } finally { UnloadProviders(providers); } }
internal ResXResourceReader(Stream stream, ITypeResolutionService typeResolver, IAliasResolver aliasResolver) { _stream = stream; _typeResolver = typeResolver; _aliasResolver = aliasResolver ?? new ReaderAliasResolver(); }
public TypeResolver(IDisposable container, ITypeResolutionService type_resolver) { this.type_resolver = type_resolver; this.container = container; }
public NemerleCodeBehindEventBinder(EnvDTE.FileCodeModel fileCodeModel, ITypeResolutionService typeResolutionService) { _fileCodeModel = fileCodeModel; _typeResolutionService = typeResolutionService; }
public CustomBinder (ITypeResolutionService _typeResolver) { // nulls ok typeResolver = _typeResolver; }
private ArgumentPanel CreateEditingPanel(Configuration.Field field) { IValueInfoService metaDataService = (IValueInfoService)GetService(typeof(IValueInfoService)); ValueInfo argument = metaDataService.GetInfo(field.ValueName); if (argument == null) { throw new ArgumentNullException("Field"); } ArgumentPanel argumentPanel = null; ITypeResolutionService loaderService = (ITypeResolutionService)GetService(typeof(ITypeResolutionService)); Type argType = argument.Type; if (argType == null) { throw new TypeLoadException( String.Format( CultureInfo.CurrentCulture, Properties.Resources.WizardGatheringService_CannotLoadTypeStepField, argument.Name, this.Configuration.Title)); } if (argType == typeof(bool) || // The type is a simple boolean value, so let's use ArgumentPanelBool argType == typeof(Nullable <bool>)) { argumentPanel = new ArgumentPanelBool(); } else { if (!string.IsNullOrEmpty(field.PanelType)) { Type paneltype = loaderService.GetType(field.PanelType); argumentPanel = (ArgumentPanelTypeEditor)Activator.CreateInstance(paneltype); } else { argumentPanel = new ArgumentPanelTypeEditor(); } //First try to use any UITypeEditor defined for our type Type editorType = field.Editor == null ? null : loaderService.GetType(field.Editor.Type); if (editorType != null) { UITypeEditor editorInstance = (UITypeEditor)Activator.CreateInstance(editorType); if (editorInstance is IAttributesConfigurable) { ImmutableKeyStringDictionary values = new ImmutableKeyStringDictionary(); if (field.Editor.AnyAttr != null) { foreach (XmlAttribute xattr in field.Editor.AnyAttr) { values.Add(xattr.Name, xattr.Value); } } ((IAttributesConfigurable)editorInstance).Configure(values); } ((ArgumentPanelTypeEditor)argumentPanel).EditorInstance = editorInstance; } ((ArgumentPanelTypeEditor)argumentPanel).ConverterInstance = argument.Converter; } argumentPanel.FieldConfig = field; this.Arguments[argument] = argumentPanel; return(argumentPanel); }
public override string GetValueTypeName (ITypeResolutionService typeResolver) { return InternalGetValueType (typeResolver); }
private object GenerateObjectFromDataNodeInfo(DataNodeInfo dataNodeInfo, ITypeResolutionService typeResolver) { object result = null; string mimeTypeName = dataNodeInfo.MimeType; // default behavior: if we dont have a type name, it's a string string typeName = string.IsNullOrEmpty(dataNodeInfo.TypeName) ? MultitargetUtil.GetAssemblyQualifiedName(typeof(string), this.typeNameConverter) : dataNodeInfo.TypeName; if (!string.IsNullOrEmpty(mimeTypeName)) { if (string.Equals(mimeTypeName, ResXResourceWriter.BinSerializedObjectMimeType) || string.Equals(mimeTypeName, ResXResourceWriter.Beta2CompatSerializedObjectMimeType) || string.Equals(mimeTypeName, ResXResourceWriter.CompatBinSerializedObjectMimeType)) { string text = dataNodeInfo.ValueData; byte[] serializedData = FromBase64WrappedString(text); if (binaryFormatter == null) { binaryFormatter = new BinaryFormatter { Binder = new ResXSerializationBinder(typeResolver) }; } IFormatter formatter = binaryFormatter; if (serializedData != null && serializedData.Length > 0) { result = formatter.Deserialize(new MemoryStream(serializedData)); if (result is ResXNullRef) { result = null; } } } else if (string.Equals(mimeTypeName, ResXResourceWriter.ByteArraySerializedObjectMimeType)) { if (!string.IsNullOrEmpty(typeName)) { Type type = ResolveType(typeName, typeResolver); if (type != null) { TypeConverter tc = TypeDescriptor.GetConverter(type); if (tc.CanConvertFrom(typeof(byte[]))) { string text = dataNodeInfo.ValueData; byte[] serializedData = FromBase64WrappedString(text); if (serializedData != null) { result = tc.ConvertFrom(serializedData); } } } else { string newMessage = string.Format(SR.TypeLoadException, typeName, dataNodeInfo.ReaderPosition.Y, dataNodeInfo.ReaderPosition.X); XmlException xml = new XmlException(newMessage, null, dataNodeInfo.ReaderPosition.Y, dataNodeInfo.ReaderPosition.X); TypeLoadException newTle = new TypeLoadException(newMessage, xml); throw newTle; } } } } else if (!string.IsNullOrEmpty(typeName)) { Type type = ResolveType(typeName, typeResolver); if (type != null) { if (type == typeof(ResXNullRef)) { result = null; } else if (typeName.IndexOf("System.Byte[]") != -1 && typeName.IndexOf("mscorlib") != -1) { // Handle byte[]'s, which are stored as base-64 encoded strings. // We can't hard-code byte[] type name due to version number // updates & potential whitespace issues with ResX files. result = FromBase64WrappedString(dataNodeInfo.ValueData); } else { TypeConverter tc = TypeDescriptor.GetConverter(type); if (tc.CanConvertFrom(typeof(string))) { string text = dataNodeInfo.ValueData; try { result = tc.ConvertFromInvariantString(text); } catch (NotSupportedException nse) { string newMessage = string.Format(SR.NotSupported, typeName, dataNodeInfo.ReaderPosition.Y, dataNodeInfo.ReaderPosition.X, nse.Message); XmlException xml = new XmlException(newMessage, nse, dataNodeInfo.ReaderPosition.Y, dataNodeInfo.ReaderPosition.X); NotSupportedException newNse = new NotSupportedException(newMessage, xml); throw newNse; } } else { Debug.WriteLine("Converter for " + type.FullName + " doesn't support string conversion"); } } } else { string newMessage = string.Format(SR.TypeLoadException, typeName, dataNodeInfo.ReaderPosition.Y, dataNodeInfo.ReaderPosition.X); XmlException xml = new XmlException(newMessage, null, dataNodeInfo.ReaderPosition.Y, dataNodeInfo.ReaderPosition.X); TypeLoadException newTle = new TypeLoadException(newMessage, xml); throw newTle; } } else { // if mimeTypeName and typeName are not filled in, the value must be a string Debug.Assert(value is string, "Resource entries with no Type or MimeType must be encoded as strings"); } return(result); }
private static TypeConverter CreateAndConfigureConverter(Config.Argument argument, ITypeResolutionService resolution, TypeConverter converter) { converter = Activator.CreateInstance(resolution.GetType(argument.Converter.Type, true)) as TypeConverter; if (converter == null) { // Couldn't do implicit cast to TypeConverter. throw new ArgumentException(String.Format( System.Globalization.CultureInfo.CurrentCulture, Properties.Resources.General_TypeIsNotAssignable, converter, typeof(TypeConverter))); } // Check if converter is configurable. if (converter is IAttributesConfigurable) { Recipe.Configure((IAttributesConfigurable)converter, argument.Converter.AnyAttr); } return(converter); }
/// <devdoc> /// Get the FQ type name for this datanode. /// We return typeof(object) for ResXNullRef /// </devdoc> public string GetValueTypeName(ITypeResolutionService typeResolver) { // the type name here is always a FQN if (!string.IsNullOrEmpty(typeName)) { return (typeName == MultitargetUtil.GetAssemblyQualifiedName(typeof(ResXNullRef), this.typeNameConverter) ? MultitargetUtil.GetAssemblyQualifiedName(typeof(object), this.typeNameConverter) : typeName); } string result = FileRefType; Type objectType = null; // do we have a fileref? if (result != null) { // try to resolve this type objectType = ResolveType(FileRefType, typeResolver); } else if (nodeInfo != null) { // we dont have a fileref, try to resolve the type of the datanode result = nodeInfo.TypeName; // if typename is null, the default is just a string if (string.IsNullOrEmpty(result)) { // we still dont know... do we have a mimetype? if yes, our only option is to // deserialize to know what we're dealing with... very inefficient... if (!string.IsNullOrEmpty(nodeInfo.MimeType)) { object insideObject = null; try { insideObject = GenerateObjectFromDataNodeInfo(nodeInfo, typeResolver); } catch (Exception ex) { // it'd be better to catch SerializationException but the underlying type resolver // can throw things like FileNotFoundException which is kinda confusing, so I am catching all here.. if (ClientUtils.IsCriticalException(ex)) { throw; } // something went wrong, type is not specified at all or stream is corrupted // return system.object result = MultitargetUtil.GetAssemblyQualifiedName(typeof(object), this.typeNameConverter); } if (insideObject != null) { result = MultitargetUtil.GetAssemblyQualifiedName(insideObject.GetType(), this.typeNameConverter); } } else { // no typename, no mimetype, we have a string... result = MultitargetUtil.GetAssemblyQualifiedName(typeof(string), this.typeNameConverter); } } else { objectType = ResolveType(nodeInfo.TypeName, typeResolver); } } if (objectType != null) { if (objectType == typeof(ResXNullRef)) { result = MultitargetUtil.GetAssemblyQualifiedName(typeof(object), this.typeNameConverter); } else { result = MultitargetUtil.GetAssemblyQualifiedName(objectType, this.typeNameConverter); } } return(result); }
internal ResXResourceReader(TextReader reader, ITypeResolutionService typeResolver, IAliasResolver aliasResolver) { _reader = reader; _typeResolver = typeResolver; _aliasResolver = aliasResolver ?? new ReaderAliasResolver(); }
internal ResXSerializationBinder(ITypeResolutionService typeResolver) { this.typeResolver = typeResolver; }
public Object GetValue(ITypeResolutionService typeResolver) { return(value); }
public CustomBinder(ITypeResolutionService _typeResolver) { // nulls ok typeResolver = _typeResolver; }
/// <include file='doc\ResXResourceReader.uex' path='docs/doc[@for="ResXResourceReader.FromFileContents1"]/*' /> /// <internalonly/> /// <devdoc> /// Creates a reader with the specified file contents. /// </devdoc> public static ResXResourceReader FromFileContents(string fileContents, ITypeResolutionService typeResolver) { ResXResourceReader result = new ResXResourceReader(typeResolver); result.fileContents = fileContents; return result; }
public override object GetValue(ITypeResolutionService typeResolver) { return(DeserializeObject(typeResolver)); }
public ResXResourceReader(string fileName, ITypeResolutionService typeResolver) : this(fileName, typeResolver, (IAliasResolver)null) { }
public static ResXResourceReader FromFileContents (String fileContents, ITypeResolutionService typeResolver) { return new ResXResourceReader (new StringReader(fileContents), typeResolver); }
public ResXResourceReader(TextReader reader, ITypeResolutionService typeResolver) : this(reader, typeResolver, (IAliasResolver)null) { }
public object GetValue(ITypeResolutionService typeResolver) { if (this.value != null) { return this.value; } object obj2 = null; if (this.FileRefFullPath != null) { if (this.ResolveType(this.FileRefType, typeResolver) != null) { if (this.FileRefTextEncoding != null) { this.fileRef = new ResXFileRef(this.FileRefFullPath, this.FileRefType, Encoding.GetEncoding(this.FileRefTextEncoding)); } else { this.fileRef = new ResXFileRef(this.FileRefFullPath, this.FileRefType); } return TypeDescriptor.GetConverter(typeof(ResXFileRef)).ConvertFrom(this.fileRef.ToString()); } TypeLoadException exception = new TypeLoadException(System.Windows.Forms.SR.GetString("TypeLoadExceptionShort", new object[] { this.FileRefType })); throw exception; } if ((obj2 == null) && (this.nodeInfo.ValueData != null)) { return this.GenerateObjectFromDataNodeInfo(this.nodeInfo, typeResolver); } return null; }
public ResXResourceReader(string fileName, ITypeResolutionService typeResolver) : this(fileName) { this.typeresolver = typeResolver; }
private System.Type ResolveType(string typeName, ITypeResolutionService typeResolver) { System.Type type = null; if (typeResolver != null) { type = typeResolver.GetType(typeName, false); if (type == null) { string[] strArray = typeName.Split(new char[] { ',' }); if ((strArray != null) && (strArray.Length >= 2)) { string name = strArray[0].Trim(); string str2 = strArray[1].Trim(); name = name + ", " + str2; type = typeResolver.GetType(name, false); } } } if (type == null) { type = System.Type.GetType(typeName, false); } return type; }
public override object GetValue (ITypeResolutionService typeResolver) { return DeserializeObject (typeResolver); }
public Object GetValue (ITypeResolutionService typeResolver) { return value; }
public ResXResourceReader(Stream stream, ITypeResolutionService typeResolver) : this(stream) { this.typeresolver = typeResolver; }
public ResXResourceReader (Stream stream, ITypeResolutionService typeResolver) : this (stream) { this.typeresolver = typeResolver; }
public ResXResourceReader(TextReader reader, ITypeResolutionService typeResolver) : this(reader) { this.typeresolver = typeResolver; }
protected virtual Type GetType(IDesignerHost host, AssemblyName assemblyName, string typeName, bool reference) { ITypeResolutionService ts = null; Type type = null; if (typeName == null) { throw new ArgumentNullException(nameof(typeName)); } if (host != null) { ts = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService)); } if (ts != null) { if (reference) { if (assemblyName != null) { ts.ReferenceAssembly(assemblyName); type = ts.GetType(typeName); } else { // Just try loading the type. If we succeed, then use this as the // reference. type = ts.GetType(typeName); if (type == null) { type = Type.GetType(typeName); } if (type != null) { ts.ReferenceAssembly(type.Assembly.GetName()); } } } else { if (assemblyName != null) { Assembly a = ts.GetAssembly(assemblyName); if (a != null) { type = a.GetType(typeName); } } if (type == null) { type = ts.GetType(typeName); } } } else { if (!string.IsNullOrEmpty(typeName)) { if (assemblyName != null) { Assembly a = null; try { a = Assembly.Load(assemblyName); } catch (FileNotFoundException) { } catch (BadImageFormatException) { } catch (IOException) { } if (a == null && assemblyName.CodeBase != null && assemblyName.CodeBase.Length > 0) { try { a = Assembly.LoadFrom(assemblyName.CodeBase); } catch (FileNotFoundException) { } catch (BadImageFormatException) { } catch (IOException) { } } if (a != null) { type = a.GetType(typeName); } } if (type == null) { type = Type.GetType(typeName, false); } } } return(type); }
public override string GetValueTypeName(ITypeResolutionService typeResolver) { return(InternalGetValueType(typeResolver)); }
internal Type GetControlType(string tagName, IDictionary attribs, bool throwOnError) { string str; string str2 = this._nsRegisterEntry.Namespace; if (string.IsNullOrEmpty(str2)) { str = tagName; } else { str = str2 + "." + tagName; } if (this._assembly != null) { Type type = null; if (throwOnError) { try { return(this._assembly.GetType(str, true, true)); } catch (FileNotFoundException) { throw; } catch (FileLoadException) { throw; } catch (BadImageFormatException) { throw; } catch { return(type); } } return(this._assembly.GetType(str, false, true)); } if (this._parser.FInDesigner && (this._parser.DesignerHost != null)) { if (this._parser.DesignerHost.RootComponent != null) { WebFormsRootDesigner designer = this._parser.DesignerHost.GetDesigner(this._parser.DesignerHost.RootComponent) as WebFormsRootDesigner; if (designer != null) { WebFormsReferenceManager referenceManager = designer.ReferenceManager; if (referenceManager != null) { Type type2 = referenceManager.GetType(this._nsRegisterEntry.TagPrefix, tagName); if (type2 != null) { return(type2); } } } } ITypeResolutionService service = (ITypeResolutionService)this._parser.DesignerHost.GetService(typeof(ITypeResolutionService)); if (service != null) { Type type3 = service.GetType(str, false, true); if (type3 != null) { return(type3); } } } if (!HostingEnvironment.IsHosted) { return(null); } return(BuildManager.GetTypeFromCodeAssembly(str, true)); }
private object GenerateObjectFromDataNodeInfo(DataNodeInfo dataNodeInfo, ITypeResolutionService typeResolver) { object obj2 = null; string mimeType = dataNodeInfo.MimeType; string typeName = ((dataNodeInfo.TypeName == null) || (dataNodeInfo.TypeName.Length == 0)) ? MultitargetUtil.GetAssemblyQualifiedName(typeof(string), this.typeNameConverter) : dataNodeInfo.TypeName; if ((mimeType != null) && (mimeType.Length > 0)) { if ((string.Equals(mimeType, ResXResourceWriter.BinSerializedObjectMimeType) || string.Equals(mimeType, ResXResourceWriter.Beta2CompatSerializedObjectMimeType)) || string.Equals(mimeType, ResXResourceWriter.CompatBinSerializedObjectMimeType)) { byte[] buffer = FromBase64WrappedString(dataNodeInfo.ValueData); if (this.binaryFormatter == null) { this.binaryFormatter = new BinaryFormatter(); this.binaryFormatter.Binder = new ResXSerializationBinder(typeResolver); } IFormatter binaryFormatter = this.binaryFormatter; if ((buffer != null) && (buffer.Length > 0)) { obj2 = binaryFormatter.Deserialize(new MemoryStream(buffer)); if (obj2 is ResXNullRef) { obj2 = null; } } return obj2; } if (string.Equals(mimeType, ResXResourceWriter.SoapSerializedObjectMimeType) || string.Equals(mimeType, ResXResourceWriter.CompatSoapSerializedObjectMimeType)) { byte[] buffer2 = FromBase64WrappedString(dataNodeInfo.ValueData); if ((buffer2 != null) && (buffer2.Length > 0)) { obj2 = this.CreateSoapFormatter().Deserialize(new MemoryStream(buffer2)); if (obj2 is ResXNullRef) { obj2 = null; } } return obj2; } if ((!string.Equals(mimeType, ResXResourceWriter.ByteArraySerializedObjectMimeType) || (typeName == null)) || (typeName.Length <= 0)) { return obj2; } System.Type type = this.ResolveType(typeName, typeResolver); if (type != null) { TypeConverter converter = TypeDescriptor.GetConverter(type); if (converter.CanConvertFrom(typeof(byte[]))) { byte[] buffer3 = FromBase64WrappedString(dataNodeInfo.ValueData); if (buffer3 != null) { obj2 = converter.ConvertFrom(buffer3); } } return obj2; } string str6 = System.Windows.Forms.SR.GetString("TypeLoadException", new object[] { typeName, dataNodeInfo.ReaderPosition.Y, dataNodeInfo.ReaderPosition.X }); XmlException exception = new XmlException(str6, null, dataNodeInfo.ReaderPosition.Y, dataNodeInfo.ReaderPosition.X); TypeLoadException exception2 = new TypeLoadException(str6, exception); throw exception2; } if ((typeName == null) || (typeName.Length <= 0)) { return obj2; } System.Type type2 = this.ResolveType(typeName, typeResolver); if (type2 != null) { if (type2 == typeof(ResXNullRef)) { return null; } if ((typeName.IndexOf("System.Byte[]") != -1) && (typeName.IndexOf("mscorlib") != -1)) { return FromBase64WrappedString(dataNodeInfo.ValueData); } TypeConverter converter2 = TypeDescriptor.GetConverter(type2); if (!converter2.CanConvertFrom(typeof(string))) { return obj2; } string valueData = dataNodeInfo.ValueData; try { return converter2.ConvertFromInvariantString(valueData); } catch (NotSupportedException exception3) { string str8 = System.Windows.Forms.SR.GetString("NotSupported", new object[] { typeName, dataNodeInfo.ReaderPosition.Y, dataNodeInfo.ReaderPosition.X, exception3.Message }); XmlException innerException = new XmlException(str8, exception3, dataNodeInfo.ReaderPosition.Y, dataNodeInfo.ReaderPosition.X); NotSupportedException exception5 = new NotSupportedException(str8, innerException); throw exception5; } } string message = System.Windows.Forms.SR.GetString("TypeLoadException", new object[] { typeName, dataNodeInfo.ReaderPosition.Y, dataNodeInfo.ReaderPosition.X }); XmlException inner = new XmlException(message, null, dataNodeInfo.ReaderPosition.Y, dataNodeInfo.ReaderPosition.X); TypeLoadException exception7 = new TypeLoadException(message, inner); throw exception7; }
/// <summary> /// Creates the necessary components associated with this data adapter instance /// </summary> /// <param name="host">The designer host</param> /// <returns>The components created by this toolbox item</returns> protected override IComponent[] CreateComponentsCore(IDesignerHost host) { DbProviderFactory fact = DbProviderFactories.GetFactory("Npgsql"); DbDataAdapter dataAdapter = fact.CreateDataAdapter(); IContainer container = host.Container; using (DbCommand adapterCommand = fact.CreateCommand()) { adapterCommand.DesignTimeVisible = false; dataAdapter.SelectCommand = (DbCommand)((ICloneable)adapterCommand).Clone(); container.Add(dataAdapter.SelectCommand, GenerateName(container, "SelectCommand")); dataAdapter.InsertCommand = (DbCommand)((ICloneable)adapterCommand).Clone(); container.Add(dataAdapter.InsertCommand, GenerateName(container, "InsertCommand")); dataAdapter.UpdateCommand = (DbCommand)((ICloneable)adapterCommand).Clone(); container.Add(dataAdapter.UpdateCommand, GenerateName(container, "UpdateCommand")); dataAdapter.DeleteCommand = (DbCommand)((ICloneable)adapterCommand).Clone(); container.Add(dataAdapter.DeleteCommand, GenerateName(container, "DeleteCommand")); } ITypeResolutionService typeResService = (ITypeResolutionService)host.GetService(typeof(ITypeResolutionService)); if (typeResService != null) { typeResService.ReferenceAssembly(dataAdapter.GetType().Assembly.GetName()); } container.Add(dataAdapter); List <IComponent> list = new List <IComponent>(); list.Add(dataAdapter); // Show the connection wizard if we have a type for it if (_wizard != null) { using (Form wizard = (Form)Activator.CreateInstance(_wizard, new object[] { host, dataAdapter })) { wizard.ShowDialog(); } } if (dataAdapter.SelectCommand != null) { list.Add(dataAdapter.SelectCommand); } if (dataAdapter.InsertCommand != null) { list.Add(dataAdapter.InsertCommand); } if (dataAdapter.DeleteCommand != null) { list.Add(dataAdapter.DeleteCommand); } if (dataAdapter.UpdateCommand != null) { list.Add(dataAdapter.UpdateCommand); } return(list.ToArray()); }
public string GetValueTypeName(ITypeResolutionService typeResolver) { if ((this.typeName != null) && (this.typeName.Length > 0)) { if (this.typeName.Equals(MultitargetUtil.GetAssemblyQualifiedName(typeof(ResXNullRef), this.typeNameConverter))) { return MultitargetUtil.GetAssemblyQualifiedName(typeof(object), this.typeNameConverter); } return this.typeName; } string fileRefType = this.FileRefType; System.Type type = null; if (fileRefType != null) { type = this.ResolveType(this.FileRefType, typeResolver); } else if (this.nodeInfo != null) { fileRefType = this.nodeInfo.TypeName; if ((fileRefType == null) || (fileRefType.Length == 0)) { if ((this.nodeInfo.MimeType != null) && (this.nodeInfo.MimeType.Length > 0)) { object obj2 = null; try { obj2 = this.GenerateObjectFromDataNodeInfo(this.nodeInfo, typeResolver); } catch (Exception exception) { if (System.Windows.Forms.ClientUtils.IsCriticalException(exception)) { throw; } fileRefType = MultitargetUtil.GetAssemblyQualifiedName(typeof(object), this.typeNameConverter); } if (obj2 != null) { fileRefType = MultitargetUtil.GetAssemblyQualifiedName(obj2.GetType(), this.typeNameConverter); } } else { fileRefType = MultitargetUtil.GetAssemblyQualifiedName(typeof(string), this.typeNameConverter); } } else { type = this.ResolveType(this.nodeInfo.TypeName, typeResolver); } } if (type == null) { return fileRefType; } if (type == typeof(ResXNullRef)) { return MultitargetUtil.GetAssemblyQualifiedName(typeof(object), this.typeNameConverter); } return MultitargetUtil.GetAssemblyQualifiedName(type, this.typeNameConverter); }
private ResXResourceReader(ITypeResolutionService typeResolver) { _typeResolver = typeResolver; _aliasResolver = new ReaderAliasResolver(); }
public string GetValueTypeName (ITypeResolutionService typeResolver) { return type.AssemblyQualifiedName; }
public ResXResourceReader(string fileName, ITypeResolutionService typeResolver) : this(fileName, typeResolver, null) { }
public ResXResourceReader (TextReader reader, ITypeResolutionService typeResolver) : this (reader) { this.typeresolver = typeResolver; }
internal ResXResourceReader(string fileName, ITypeResolutionService typeResolver, IAliasResolver aliasResolver) { _fileName = fileName; _typeResolver = typeResolver; _aliasResolver = aliasResolver ?? new ReaderAliasResolver(); }
public ResXResourceReader (string fileName, ITypeResolutionService typeResolver) : this (fileName) { this.typeresolver = typeResolver; }