public BuildTaskOverrider(IServiceProvider serviceProvider, Func <string> promptMessageFormatter, Func <string> doNotPromptAgainMessageFormatter, string automationId, BuildTaskInfo overrideBuildTask)
 {
     this.serviceProvider                  = serviceProvider;
     this.promptMessageFormatter           = promptMessageFormatter;
     this.doNotPromptAgainMessageFormatter = doNotPromptAgainMessageFormatter;
     this.promptAutomationId               = automationId;
     this.overrideBuildTask                = overrideBuildTask;
 }
Beispiel #2
0
        private BuildTaskInfoPopulator CreateLargeImageBuildTaskPopulator()
        {
            Dictionary <string, string> strs = new Dictionary <string, string>()
            {
                { "CopyToOutputDirectory", "PreserveNewest" }
            };
            BuildTaskInfo buildTaskInfo = new BuildTaskInfo("Content", strs);

            return(XamlProject.CreateLargeImagePopulator((this.IsControlLibrary ? StringTable.ImageScalabilityWarningSilverlightControlLibrary : StringTable.ImageScalabilityWarningSilverlightApplication), buildTaskInfo, base.Services));
        }
Beispiel #3
0
        public static IProjectItem CreateDesignDataFile(Type type, string dataSourceName, IProjectContext projectContext, bool isDesignTimeCreatable)
        {
            string path1   = Path.Combine(Path.GetDirectoryName(projectContext.ProjectPath), DataSetContext.SampleData.DataRootFolder);
            string str     = dataSourceName ?? type.Name;
            string path2_1 = str + ".xaml";
            string path2   = Path.Combine(path1, path2_1);
            int    num     = 1;

            while (File.Exists(path2))
            {
                string path2_2 = str + num.ToString((IFormatProvider)CultureInfo.InvariantCulture) + ".xaml";
                path2 = Path.Combine(path1, path2_2);
                ++num;
            }
            string          path3           = Path.GetTempFileName() + ".xaml";
            IProjectContext projectContext1 = projectContext;

            if (!isDesignTimeCreatable)
            {
                projectContext1 = (IProjectContext)(projectContext as TypeReflectingProjectContext) ?? (IProjectContext) new TypeReflectingProjectContext(projectContext);
            }
            DocumentContext documentContext = new DocumentContext(projectContext1, (IDocumentLocator) new DocumentLocator(path2), false);
            IType           type1           = documentContext.TypeResolver.GetType(type);
            DocumentNode    node            = new DesignDataGenerator(type1, (IDocumentContext)documentContext).Build();

            try
            {
                using (StreamWriter text = File.CreateText(path3))
                {
                    using (XamlDocument xamlDocument = new XamlDocument((IDocumentContext)documentContext, (ITypeId)type1, (ITextBuffer) new SimpleTextBuffer(), DocumentEncodingHelper.DefaultEncoding, (IXamlSerializerFilter) new DefaultXamlSerializerFilter()))
                        new XamlSerializer((IDocumentRoot)xamlDocument, (IXamlSerializerFilter) new DefaultXamlSerializerFilter()).Serialize(node, (TextWriter)text);
                }
                BuildTaskInfo        buildTaskInfo = new BuildTaskInfo(DocumentContextHelper.DesignDataBuildTask, (IDictionary <string, string>) new Dictionary <string, string>());
                DocumentCreationInfo creationInfo  = new DocumentCreationInfo()
                {
                    BuildTaskInfo   = buildTaskInfo,
                    TargetFolder    = path1,
                    TargetPath      = path2,
                    SourcePath      = path3,
                    CreationOptions = CreationOptions.SilentlyOverwrite | CreationOptions.SilentlyOverwriteReadOnly | CreationOptions.DoNotSelectCreatedItems | CreationOptions.DoNotSetDefaultImportPath
                };
                return(((IProject)projectContext.GetService(typeof(IProject))).AddItem(creationInfo));
            }
            finally
            {
                try
                {
                    File.Delete(path3);
                }
                catch
                {
                }
            }
        }
Beispiel #4
0
        protected static BuildTaskInfoPopulator CreateLargeImagePopulator(string baseWarningMessage, BuildTaskInfo overrideBuildTask, IServiceProvider services)
        {
            Func <string> promptMessageFormatter = (Func <string>)(() => string.Format((IFormatProvider)CultureInfo.CurrentCulture, baseWarningMessage, new object[1]
            {
                (object)XamlProject.GetLargeImageThreshold(services).ToString((IFormatProvider)CultureInfo.CurrentCulture)
            }));
            Func <string> doNotPromptAgainMessageFormatter = (Func <string>)(() => string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.ImageScalabilityWarningDoNotShowAgainMessage, new object[1]
            {
                (object)XamlProject.GetLargeImageThreshold(services).ToString((IFormatProvider)CultureInfo.CurrentCulture)
            }));
            IBuildTaskOverrider buildTaskOverrider = (IBuildTaskOverrider) new BuildTaskOverrider(services, promptMessageFormatter, doNotPromptAgainMessageFormatter, "LargeImageDialog", overrideBuildTask);

            return((BuildTaskInfoPopulator) new LargeImageBuildTaskInfoPopulator((ICreationInfoFilter) new LargeImageCreationInfoFilter(services), buildTaskOverrider));
        }