/// <summary>
 /// Initializes a new instance of the <see cref="CodeRushProxy"/> class.
 /// </summary>
 public CodeRushProxy()
 {
   this.solution = GetNonNull(CodeRush.Solution, "CodeRush.Solution.");
   this.documents = GetNonNull(CodeRush.Documents, "CodeRush.Documents");
   this.file = GetNonNull(CodeRush.File, "CodeRush.File");
   this.textBuffers = GetNonNull(CodeRush.TextBuffers, "CodeRush.TextBuffers");
   this.language = GetNonNull(CodeRush.Language, "CodeRush.Language");
   this.markers = GetNonNull(CodeRush.Markers, "CodeRush.Markers");
   var source = GetNonNull(CodeRush.Source, "CodeRush.Source");
   this.source = new SourceModelProxy(source);
   this.undoStack = GetNonNull(CodeRush.UndoStack, "CodeRush.UndoStack");
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CodeRushProxy"/> class.
        /// </summary>
        public CodeRushProxy()
        {
            this.solution    = GetNonNull(CodeRush.Solution, "CodeRush.Solution.");
            this.documents   = GetNonNull(CodeRush.Documents, "CodeRush.Documents");
            this.file        = GetNonNull(CodeRush.File, "CodeRush.File");
            this.textBuffers = GetNonNull(CodeRush.TextBuffers, "CodeRush.TextBuffers");
            this.language    = GetNonNull(CodeRush.Language, "CodeRush.Language");
            this.markers     = GetNonNull(CodeRush.Markers, "CodeRush.Markers");
            var source = GetNonNull(CodeRush.Source, "CodeRush.Source");

            this.source    = new SourceModelProxy(source);
            this.undoStack = GetNonNull(CodeRush.UndoStack, "CodeRush.UndoStack");
        }
Beispiel #3
0
        private static ITextBuffer LoadResourceFromStream(ITextBufferService textBufferService, Stream stream, out Encoding encoding)
        {
            ITextBuffer textBuffer;

            using (StreamReader streamReader = new StreamReader(stream))
            {
                string end = streamReader.ReadToEnd();
                encoding = streamReader.CurrentEncoding;
                ITextBuffer textBuffer1 = textBufferService.CreateTextBuffer();
                textBuffer1.SetText(0, textBuffer1.Length, end);
                textBuffer = textBuffer1;
            }
            return(textBuffer);
        }
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.viewNodeManager != null)
         {
             this.viewNodeManager.DisposeInternal();
             this.viewNodeManager = null;
         }
         this.effectManager          = null;
         this.instanceBuilderFactory = null;
         this.metadataFactory        = null;
         this.serializationContext   = null;
         this.documentRootResolver   = null;
         this.viewRootResolver       = null;
         this.parentContext          = null;
         this.nameScope         = null;
         this.textBufferService = null;
         this.containerRoot     = null;
         if (this.instanceDictionary != null)
         {
             this.instanceDictionary.Clear();
         }
         if (this.exceptionDictionary != null)
         {
             this.exceptionDictionary.Clear();
         }
         if (this.warningDictionary != null)
         {
             this.warningDictionary.Clear();
         }
         if (this.userControlInstances != null)
         {
             foreach (ViewNode userControlInstance in this.userControlInstances)
             {
                 userControlInstance.Dispose();
             }
             this.userControlInstances.Clear();
         }
     }
 }
 protected InstanceBuilderContextBase(IPlatform platform, IDocumentContext documentContext, IDocumentRootResolver documentRootResolver, IViewRootResolver viewRootResolver, ITypeMetadataFactory metadataFactory, INameScope nameScope, IInstanceBuilderContext parentContext, bool useShadowProperties, ITextBufferService textBufferService, DocumentNode alternateSiteNode)
 {
     this.documentContext                   = documentContext;
     this.platform                          = platform;
     this.effectManager                     = platform.EffectManager;
     this.instanceBuilderFactory            = platform.InstanceBuilderFactory;
     this.documentRootResolver              = documentRootResolver;
     this.viewRootResolver                  = viewRootResolver;
     this.metadataFactory                   = metadataFactory;
     this.AllowPostponingResourceEvaluation = true;
     this.viewNodeManager                   = this.platform.Create();
     this.viewNodeManager.Initialize(this);
     this.userControlInstances = new HashSet <ViewNode>();
     this.currentlyInstantiatingUserControlPreviews = new HashSet <string>();
     this.instanceDictionary  = this.platform.CreateInstanceDictionary(this.viewNodeManager);
     this.exceptionDictionary = new Microsoft.Expression.DesignModel.InstanceBuilders.ExceptionDictionary(this.viewNodeManager);
     this.warningDictionary   = new Microsoft.Expression.DesignModel.InstanceBuilders.WarningDictionary(this.viewNodeManager);
     this.nameScope           = nameScope;
     this.useShadowProperties = useShadowProperties;
     this.shouldRegisterInstantiatedElements = true;
     this.parentContext     = parentContext;
     this.textBufferService = textBufferService;
     this.alternateSiteNode = alternateSiteNode;
 }
 public SceneXamlDocument(IDocumentContext documentContext, IUndoService undoService, ITextBufferService textBufferService)
     : this(documentContext, undoService, PlatformTypes.Object, textBufferService.CreateTextBuffer(), DocumentEncodingHelper.DefaultEncoding)
 {
 }
        private ThemeContentProvider.SystemThemeContentProvider GetCachedThemeContent(Dictionary <ThemeContentProvider.PlatformSpecificDocumentReference, ThemeContentProvider.SystemThemeContentProvider> themeCache, ThemeManager manager, IProjectContext projectContext, DocumentReference reference, IAssembly themeAssembly, string themeAssemblyPath, ITextBufferService textBufferService)
        {
            ThemeContentProvider.PlatformSpecificDocumentReference key = new ThemeContentProvider.PlatformSpecificDocumentReference(reference, projectContext != null ? projectContext.TargetFramework : (FrameworkName)null);
            ThemeContentProvider.SystemThemeContentProvider        themeContentProvider;
            if (!themeCache.TryGetValue(key, out themeContentProvider))
            {
                Encoding    encoding;
                ITextBuffer textBuffer = themeAssembly != null?ThemeManager.LoadResource(themeAssembly, themeAssemblyPath, textBufferService, out encoding) : ThemeContentProvider.LoadReference(reference, textBufferService, out encoding);

                IDocumentLocator documentLocator = DocumentReferenceLocator.GetDocumentLocator(reference);
                IDocumentContext userContext     = projectContext == null ? (IDocumentContext)null : (IDocumentContext) new DocumentContext(projectContext, documentLocator);
                XamlDocument     theme           = manager.GetTheme(documentLocator, themeAssembly != null, userContext, textBuffer, encoding);
                if (theme != null)
                {
                    bool flag1 = false;
                    try
                    {
                        if (projectContext != null)
                        {
                            if (!projectContext.IsCapabilitySet(PlatformCapability.IsWpf))
                            {
                                if (themeAssembly != null)
                                {
                                    bool flag2 = false;
                                    foreach (IAssembly assembly in (projectContext.Platform.Metadata as PlatformTypes).DefaultAssemblyReferences)
                                    {
                                        if (assembly == themeAssembly)
                                        {
                                            flag2 = true;
                                            break;
                                        }
                                    }
                                    if (flag2)
                                    {
                                        flag1 = true;
                                        AnimationEditor.ConvertFromToAnimations(theme.RootNode);
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                        if (flag1)
                        {
                            theme = manager.GetTheme(documentLocator, themeAssembly != null, userContext, textBuffer, encoding);
                        }
                    }
                    themeContentProvider = new ThemeContentProvider.SystemThemeContentProvider(this.designerContext, theme);
                    themeCache[key]      = themeContentProvider;
                }
            }
            return(themeContentProvider);
        }
        internal static ITextBuffer LoadReference(DocumentReference documentReference, ITextBufferService textBufferService, out Encoding encoding)
        {
            encoding = (Encoding)null;
            string text;

            using (Stream stream = documentReference.GetStream(FileAccess.Read))
            {
                if (stream == null)
                {
                    return((ITextBuffer)null);
                }
                try
                {
                    text = DocumentReference.ReadDocumentContents(stream, out encoding);
                }
                catch (IOException ex)
                {
                    return((ITextBuffer)null);
                }
            }
            ITextBuffer textBuffer = textBufferService.CreateTextBuffer();

            textBuffer.SetText(0, textBuffer.Length, text);
            return(textBuffer);
        }
Beispiel #9
0
 public InstanceBuilderContext(IPlatform platform, IDocumentRootResolver documentRootResolver, ITypeMetadataFactory metadataFactory, SceneViewModel viewModel, INameScope nameScope, InstanceBuilderContext parentContext, bool useShadowProperties, ITextBufferService textBufferService, DocumentNode alternateSiteNode)
     : base(platform, viewModel.DocumentRoot.DocumentContext, documentRootResolver, (IViewRootResolver)viewModel.DesignerContext.ViewRootResolver, metadataFactory, nameScope, (IInstanceBuilderContext)parentContext, useShadowProperties, textBufferService, alternateSiteNode)
 {
     this.viewModel = viewModel;
 }
 public StandaloneInstanceBuilderContext(IDocumentContext documentContext, IViewRootResolver viewRootResolver, ITextBufferService textBufferService)
     : base(((IProjectContext)documentContext.TypeResolver).Platform, documentContext, (IDocumentRootResolver)documentContext.TypeResolver, viewRootResolver, ((IProjectContext)documentContext.TypeResolver).MetadataFactory, (INameScope) new NameScope(), (IInstanceBuilderContext)null, true, textBufferService, (DocumentNode)null)
 {
     this.overlayLayer   = ((IProjectContext)documentContext.TypeResolver).Platform.CreateOverlayLayer();
     this.projectContext = (IProjectContext)documentContext.TypeResolver;
 }
Beispiel #11
0
        public static ITextBuffer LoadResource(IAssembly assembly, string path, ITextBufferService textBufferService, out Encoding encoding)
        {
            ITextBuffer textBuffer;

            encoding = null;
            string manifestModule = assembly.ManifestModule;

            if (manifestModule.EndsWith(".DLL", StringComparison.OrdinalIgnoreCase))
            {
                manifestModule = manifestModule.Substring(0, manifestModule.Length - 4);
            }
            manifestModule = string.Concat(manifestModule, ".g");
            try
            {
                bool     flag = false;
                Assembly reflectionAssembly = AssemblyHelper.GetReflectionAssembly(assembly);
                if (reflectionAssembly != null)
                {
                    foreach (CustomAttributeData customAttributesDatum in reflectionAssembly.GetCustomAttributesData())
                    {
                        if (!(customAttributesDatum.Constructor.DeclaringType.FullName == "System.Resources.NeutralResourcesLanguageAttribute") || !(customAttributesDatum.Constructor.DeclaringType.Assembly.GetName().Name == "mscorlib") || customAttributesDatum.ConstructorArguments.Count != 2 || !(customAttributesDatum.ConstructorArguments[1].ArgumentType.FullName == "System.Resources.UltimateResourceFallbackLocation") || customAttributesDatum.ConstructorArguments[1].Value.Equals(0))
                        {
                            continue;
                        }
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    ResourceManager resourceManager = new ResourceManager(manifestModule, reflectionAssembly);
                    using (Stream stream = resourceManager.GetStream(path, CultureInfo.InvariantCulture))
                    {
                        if (stream != null)
                        {
                            textBuffer = ThemeManager.LoadResourceFromStream(textBufferService, stream, out encoding);
                            return(textBuffer);
                        }
                    }
                }
                using (Stream manifestResourceStream = assembly.GetManifestResourceStream(string.Concat(manifestModule, ".resources")))
                {
                    if (manifestResourceStream != null)
                    {
                        using (ResourceReader resourceReaders = new ResourceReader(manifestResourceStream))
                        {
                            foreach (DictionaryEntry resourceReader in resourceReaders)
                            {
                                if (string.Compare((string)resourceReader.Key, path, StringComparison.Ordinal) != 0)
                                {
                                    continue;
                                }
                                textBuffer = ThemeManager.LoadResourceFromStream(textBufferService, (Stream)resourceReader.Value, out encoding);
                                return(textBuffer);
                            }
                        }
                    }
                }
                return(null);
            }
            catch
            {
                return(null);
            }
            return(textBuffer);
        }