Exemple #1
0
 internal TextSegment(IText parent, string text, Color color, Font font)
 {
     this.mParent = parent;
     this.mText = text;
     this.mTextColor = color;
     this.mTextFont = font;
 }
Exemple #2
0
        /// <summary>
        /// Gets the set of TextChanges that describe how the text changed
        /// between old and new versions. Some containers keep track of changes between
        /// text instances and may report multiple detailed changes. Others many simply report
        /// a single change from old to new encompassing the entire text.
        /// </summary>
        public static IEnumerable<TextChange> GetTextChanges(this IText newText, IText oldText)
        {
            int newPosDelta = 0;

            var ranges = newText.GetChangeRanges(oldText).ToList();
            var textChanges = new List<TextChange>(ranges.Count);

            foreach (var range in ranges)
            {
                var newPos = range.Span.Start + newPosDelta;

                // determine where in the newText this text exists
                string newt;
                if (range.NewLength > 0)
                {
                    var span = new TextSpan(newPos, range.NewLength);
                    newt = newText.ToString(span);
                }
                else
                {
                    newt = string.Empty;
                }

                textChanges.Add(new TextChange(range.Span, newt));

                newPosDelta += range.NewLength - range.Span.Length;
            }

            return textChanges;
        }
		/// <summary>
		/// non-undoable task
		/// </summary>
		private void DoSetupFixture()
		{
			var textFactory = Cache.ServiceLocator.GetInstance<ITextFactory>();
			var stTextFactory = Cache.ServiceLocator.GetInstance<IStTextFactory>();
			m_text = textFactory.Create();
			//Cache.LangProject.TextsOC.Add(m_text);
			m_stText = stTextFactory.Create();
			m_text.ContentsOA = m_stText;
			m_para0 = m_stText.AddNewTextPara(null);
			m_para0.Contents = TsStringUtils.MakeTss("Xxxhope xxxthis xxxwill xxxdo. xxxI xxxhope.", Cache.DefaultVernWs);
			m_para1 = m_stText.AddNewTextPara(null);
			m_para1.Contents = TsStringUtils.MakeTss("Xxxcertain xxxto xxxcatch xxxa xxxfrog. xxxCertainly xxxcan. xxxOn xxxLake xxxMonroe.", Cache.DefaultVernWs);
			m_para2 = null;

			using (ParagraphParser pp = new ParagraphParser(Cache))
				foreach (IStTxtPara para in m_stText.ParagraphsOS)
					pp.Parse(para);

			m_expectedAnOcs = new List<AnalysisOccurrence>();
			foreach (IStTxtPara para in m_stText.ParagraphsOS)
				foreach (ISegment seg in para.SegmentsOS)
					for (int i = 0; i < seg.AnalysesRS.Count; i++)
						m_expectedAnOcs.Add(new AnalysisOccurrence(seg, i));

			m_expectedAnOcsPara0 = new List<AnalysisOccurrence>();
			foreach (ISegment seg in m_para0.SegmentsOS)
				for (int i = 0; i < seg.AnalysesRS.Count; i++)
					m_expectedAnOcsPara0.Add(new AnalysisOccurrence(seg, i));
		}
		public override void Initialize()
		{
			CheckDisposed();
			base.Initialize();
			//m_inMemoryCache.InitializeAnnotationDefs();
			InstallVirtuals(@"Language Explorer\Configuration\Words\AreaConfiguration.xml",
				new string[] { "SIL.FieldWorks.IText.ParagraphSegmentsVirtualHandler", "SIL.FieldWorks.IText.OccurrencesInTextsVirtualHandler" });
			m_wsVern = Cache.DefaultVernWs;
			m_wsTrans = Cache.DefaultAnalWs;
			m_text = new Text();
			Cache.LangProject.TextsOC.Add(m_text);
			m_para = new StTxtPara();
			StText text = new StText();
			m_text.ContentsOA = text;
			text.ParagraphsOS.Append(m_para);
			m_trans = new CmTranslation();
			m_para.TranslationsOC.Add(m_trans);
			kflidFT = StTxtPara.SegmentFreeTranslationFlid(Cache);
			kflidSegments = StTxtPara.SegmentsFlid(Cache);
			m_btPoss = Cache.LangProject.TranslationTagsOA.LookupPossibilityByGuid(
				LangProject.kguidTranBackTranslation);
			m_trans.TypeRA = m_btPoss;
			m_fWasUseScriptDigits = Cache.LangProject.TranslatedScriptureOA.UseScriptDigits;
			Cache.LangProject.TranslatedScriptureOA.UseScriptDigits = false;
			// do we need to set status?
		}
 public TextEditor(int x, int y)
 {
     _text = DependencyInjection.Resolve<IText>();
     _mouseInput = DependencyInjection.Resolve<IMouseInput>();
     _keyboardControl = DependencyInjection.Resolve<IKeyboardControl>();
     Position = new Vector2(x, y);
     Visible = true;
 }
Exemple #6
0
 internal TextSegment(IText parent, string text, Color color, Font font, bool isKey)
 {
     this.mParent = parent;
     this.mText = text;
     this.mTextColor = color;
     this.mTextFont = font;
     this.mIsKeySegment = isKey;
 }
 public DurationControl(int x, int y, IKeyFramesOrderer keyFramesOrderer)
 {
     _keyFramesOrderer = keyFramesOrderer;
     _subtractButton = new TextButton("-", x, y) { Click = Subtract };
     _addButton = new TextButton("+", x + 30, y) { Click = Add };
     _durationPosition = new Vector2(x + 15, y);
     _text = DependencyInjection.Resolve<IText>();
 }
 public void VisitText(IText text)
 {
     string segContent = text.Properties.Text;
     segContent = segContent.Replace("&", "&amp;");
     segContent = segContent.Replace("<", "&lt;");
     segContent = segContent.Replace(">", "&gt;");
     segContent = segContent.Replace("'", "&apos;");
     PlainText.Append(segContent);
 }
            public TrivialSyntaxTree(string fileName, SyntaxNode rootNode, ParseOptions options)
            {
                this.fileName = fileName;
                this.rootNode = rootNode;
                this.options = options;

                // TODO: HACK HACK HACK HACK HACK HACK: look away, for this is terribly inefficient
                this.text = new StringText(rootNode.GetFullText());
            }
        public TextButton(string text, int x, int y)
        {
            _guiText = DependencyInjection.Resolve<IText>();
            _mouseInput = DependencyInjection.Resolve<IMouseInput>();

            Text = text;
            Position = new Vector2(x, y);
            Visible = true;
        }
Exemple #11
0
        public static bool IsAvailable(IText text, TextSpan span)
        {
            var document = GetDocument(text);

            return document.GetSyntaxRoot()
                .DescendantNodes(span)
                .OfType<PropertyDeclarationSyntax>()
                .Where(p => CodeGeneration.IsExpandableProperty(p, document))
                .Any();
        }
		/// <summary>
		/// 
		/// </summary>
		/// <param name="stringNode"></param>
		public override void VisitStringNode(IText stringNode)
		{
			System.String text = stringNode.GetText();
			if (!preTagBeingProcessed)
			{
				text = Translate.Decode(text);
				text = ReplaceNonBreakingSpaceWithOrdinarySpace(text);
			}
			textAccumulator.Append(text);
		}
Exemple #13
0
 public LexerBase(IText text, LexerBaseCache cache)
 {
     Debug.Assert(cache != null);
     this.text = text;
     this.basis = 0;
     this.start = 0;
     this.offset = 0;
     this.textEnd = text.Length;
     this.cache = cache;
     this.chars = new char[DefaultWindowLength];
 }
Exemple #14
0
 private static IDocument GetDocument(IText text)
 {
     ProjectId projectId;
     DocumentId documentId;
     return Solution.Create(SolutionId.CreateNewId())
         .AddCSharpProject("NotifyPropertyChanged", "NotifyPropertyChanged", out projectId)
         .AddMetadataReference(projectId, MetadataReference.CreateAssemblyReference("mscorlib"))
         .AddMetadataReference(projectId, MetadataReference.CreateAssemblyReference("System"))
         .AddDocument(projectId, "ThisFile", text, out documentId)
         .GetDocument(documentId);
 }
		private void FixtureSetupInternal()
		{
			// Setup default analysis ws
			m_wsEn = Cache.ServiceLocator.WritingSystemManager.Get("en").Handle;
			m_text = Cache.ServiceLocator.GetInstance<ITextFactory>().Create();
			//Cache.LangProject.TextsOC.Add(m_text);
			Cache.LangProject.TranslatedScriptureOA = Cache.ServiceLocator.GetInstance<IScriptureFactory>().Create();
			m_para = Cache.ServiceLocator.GetInstance<IStTxtParaFactory>().Create();
			IStText text = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create();
			m_text.ContentsOA = text;
			text.ParagraphsOS.Add(m_para);
		}
		/// <summary>
		/// Rysuje tekst na obiekt renderera.
		/// </summary>
		/// <param name="text">Tekst.</param>
		/// <param name="color">Kolor.</param>
		/// <param name="into">Obiekt(utworzony wcześniej przez rodzica) w który zostanie wrysowany tekst.</param>
		public void Draw(string text, Color color, IText into)
		{
			if (into == null)
			{
				throw new ArgumentNullException("item");
			}
			else if (!(into is Objects.Internals.SystemFontObject))
			{
				throw new ArgumentException("Text object wasn't created by this class", "into");
			}
			this.DrawString(text, color, (into as Objects.Internals.SystemFontObject).Texture);
			(into as Objects.Internals.SystemFontObject).Content = text;
		}
		private void FixtureSetupInternal()
		{
			//IWritingSystem wsEn = Cache.WritingSystemFactory.get_Engine("en");
			// Setup default analysis ws
			//m_wsEn = Cache.ServiceLocator.GetInstance<ILgWritingSystemRepository>().GetObject(wsEn.WritingSystem);
			m_wsVern = Cache.DefaultVernWs;

			m_text = Cache.ServiceLocator.GetInstance<ITextFactory>().Create();
			//Cache.LangProject.TextsOC.Add(m_text);
			m_stText = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create();
			m_text.ContentsOA = m_stText;
			m_para = Cache.ServiceLocator.GetInstance<IScrTxtParaFactory>().CreateWithStyle(m_stText, ScrStyleNames.NormalParagraph);
		}
        public LedgePallete(int x, int y)
        {
            _x = x;
            _y = y;
            _mapData = DependencyInjection.Resolve<IReadonlyMapData>();
            _text = DependencyInjection.Resolve<IText>();
            _settings = DependencyInjection.Resolve<IReadOnlySettings>();
            _ledgeSelector = new LedgeSelector(x, y, YIncrement);
            _ledgeFlagsButtons = new FlipTextButton<int>[_mapData.Ledges.Length];
            CreateLedgeFlagsButtons();

            var ledgesLoader = DependencyInjection.Resolve<ILedgesLoader>();
            ledgesLoader.LedgesLoaded += UpdateLedgeFlagsButtonValues;
        }
Exemple #19
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create test data for tests.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			m_servloc = Cache.ServiceLocator;
			m_text = AddInterlinearTextToLangProj("My Interlinear Text");
			m_stTextPara = AddParaToInterlinearTextContents(m_text, "Here is a sentence I can chart.");
			m_stText = m_text.ContentsOA;
			m_tssFact = Cache.TsStrFactory;
			m_rowFact = m_servloc.GetInstance<IConstChartRowFactory>();
			m_wordGrpFact = m_servloc.GetInstance<IConstChartWordGroupFactory>();
			m_possFact = m_servloc.GetInstance<ICmPossibilityFactory>();
			m_wfiFact = m_servloc.GetInstance<IWfiWordformFactory>();
			m_mtMrkrFact = m_servloc.GetInstance<IConstChartMovedTextMarkerFactory>();
			m_clsMrkrFact = m_servloc.GetInstance<IConstChartClauseMarkerFactory>();
		}
		public override void Initialize()
		{
			CheckDisposed();
			base.Initialize();
			m_inMemoryCache.InitializeAnnotationDefs();
			InstallVirtuals(@"Language Explorer\Configuration\Words\AreaConfiguration.xml",
				new string[] { "SIL.FieldWorks.IText.ParagraphSegmentsVirtualHandler", "SIL.FieldWorks.IText.OccurrencesInTextsVirtualHandler" });
			m_text = new Text();
			Cache.LangProject.TextsOC.Add(m_text);
			m_para = new StTxtPara();
			StText text = new StText();
			m_text.ContentsOA = text;
			text.ParagraphsOS.Append(m_para);
		}
Exemple #21
0
        public void Init() {
            var mockLocalizedManager = new Mock<ILocalizedStringManager>();
            mockLocalizedManager
                .Setup(x => x.GetLocalizedString(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
                .Returns("foo {0}");

            var builder = new ContainerBuilder();
            builder.RegisterInstance(new StubCultureSelector("fr-CA")).As<ICultureSelector>();
            builder.RegisterInstance(new StubWorkContext()).As<WorkContext>();
            builder.RegisterType<StubWorkContextAccessor>().As<IWorkContextAccessor>();
            builder.RegisterInstance(mockLocalizedManager.Object);
            builder.RegisterType<Orchard.Localization.Text>().As<IText>().WithParameter(new NamedParameter("scope", "scope"));
            _container = builder.Build();
            _text = _container.Resolve<IText>();
        }
Exemple #22
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates a text for testing.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void CreateTestText()
		{
			m_txt = m_servLoc.GetInstance<ITextFactory>().Create();
			//Cache.LangProject.TextsOC.Add(m_txt);
			m_stTxt = m_servLoc.GetInstance<IStTextFactory>().Create();
			m_txt.ContentsOA = m_stTxt;
			m_txtPara = m_txt.ContentsOA.AddNewTextPara(null);

			// 0         1         2         3         4
			// 0123456789012345678901234567890123456789012
			// This is a test string for CopyObject tests.

			int hvoVernWs = Cache.DefaultVernWs;
			m_txtPara.Contents = TsStringUtils.MakeTss("This is a test string for CopyObject tests.", hvoVernWs);
		}
        /// <summary>
        /// Create a new TextReplace structure over the specified <paramref name="oldSpan"/> and having
        /// the text <paramref name="newText"/>
        /// <param name="oldSpan">Span in the previous version of IText where the replace is occuring</param>
        /// <param name="newText">Text being added to the IText</param>
        /// <param name="text">Version of the IText on which the replace occurs</param>
        /// </summary>
        public TextReplace(IText text, TextSpan oldSpan, string newText)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }

            if (newText == null)
            {
                throw new ArgumentNullException("newText");
            }

            this.text = text;
            this.oldSpan = oldSpan;
            this.newText = newText;
        }
Exemple #24
0
 protected void initText(IText textObj, string text, Vector2 position, bool enabled, bool visible, bool drawAtCenter, int transSpeed)
 {
     textObj.Initialize();
     if (textObj is GameText)
     {
         ((GameText)textObj).Text = text;
         ((GameText)textObj).Position = position;
         ((GameText)textObj).Enabled = enabled;
         ((GameText)textObj).Visible = visible;
         ((GameText)textObj).DrawAtCenter = drawAtCenter;
     }
     if (textObj is MenuText)
     {
         ((MenuText)textObj).TransitionSpeedInMilliseconds = transSpeed;
     }
 }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates a text for testing.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void CreateTestText()
		{
			m_txt = m_servLoc.GetInstance<ITextFactory>().Create();
			//Cache.LangProject.TextsOC.Add(m_txt);
			m_possTagList = Cache.LangProject.GetDefaultTextTagList();
			m_stTxt = m_servLoc.GetInstance<IStTextFactory>().Create();
			m_txt.ContentsOA = m_stTxt;
			m_txtPara = m_txt.ContentsOA.AddNewTextPara(null);

			// 0    1  2 3    4      5   6                        7    8
			// This is a test string for ReferenceAdjusterService tests.

			var hvoVernWs = Cache.DefaultVernWs;
			m_txtPara.Contents = TsStringUtils.MakeTss("This is a test string for ReferenceAdjusterService tests.", hvoVernWs);
			ParseText();
		}
		public override void Initialize()
		{
			CheckDisposed();
			base.Initialize();
			InstallVirtuals(@"Language Explorer\Configuration\Words\AreaConfiguration.xml",
				new string[] { "SIL.FieldWorks.IText.ParagraphSegmentsVirtualHandler", "SIL.FieldWorks.IText.OccurrencesInTextsVirtualHandler" });

			// Try moving this up to Fixture Setup, since we don't plan on changing the text here.
			m_text1 = LoadTestText(@"LexText\Interlinear\ITextDllTests\ParagraphParserTestTexts.xml", 1, m_textsDefn);
			m_hvoPara = m_text1.ContentsOA.ParagraphsOS[1].Hvo; // First paragraph contains no text!
			ParseTestText();

			m_tagChild = new TestTaggingChild(Cache);

			// This could change, but at least it gives a reasonably stable list to test from.
			m_textMarkupTags = m_tagChild.CreateDefaultListFromXML();
			LoadTagListHvos();
		}
		private void FixtureSetupInternal()
		{
			//IWritingSystem wsEn = Cache.WritingSystemFactory.get_Engine("en");
			// Setup default analysis ws
			//m_wsEn = Cache.ServiceLocator.GetInstance<ILgWritingSystemRepository>().GetObject(wsEn.WritingSystem);
			m_wsVern = Cache.DefaultVernWs;
			m_wsTrans = Cache.DefaultAnalWs;

			m_text = Cache.ServiceLocator.GetInstance<ITextFactory>().Create();
			//Cache.LangProject.TextsOC.Add(m_text);
			var stText = Cache.ServiceLocator.GetInstance<IStTextFactory>().Create();
			m_text.ContentsOA = stText;
			m_para = Cache.ServiceLocator.GetInstance<IScrTxtParaFactory>().CreateWithStyle(stText, ScrStyleNames.NormalParagraph);

			m_trans = m_para.GetOrCreateBT();
			Cache.LangProject.TranslatedScriptureOA.UseScriptDigits = false;
			m_tsf = Cache.TsStrFactory;
		}
Exemple #28
0
        public TextControl(IPluginHost pluginHost, sFile file)
        {
            if (!IsSupported(file.id))
                throw new NotSupportedException();

            InitializeComponent();
            this.pluginHost = pluginHost;
            this.id = file.id;
            this.fileName = System.IO.Path.GetFileNameWithoutExtension(file.name);

            itext = Create_IText(id);
            itext.Read(file.path);
            text = itext.Get_Text();

            numBlock.Maximum = text.Length - 1;
            label3.Text = "of " + numBlock.Maximum.ToString();
            numBlock_ValueChanged(null, null);
        }
 internal override CommonCompilation CreateCompilation(IText code, string path, bool isInteractive, Session session, Type returnType, DiagnosticBag diagnostics)
 {
     Compilation previousSubmission = (Compilation) session.LastSubmission;
       IEnumerable<MetadataReference> referencesForCompilation = session.GetReferencesForCompilation();
       ReadOnlyArray<string> namespacesForCompilation = session.GetNamespacesForCompilation();
       ParseOptions options = isInteractive ? ScriptEngine.DefaultInteractive : ScriptEngine.DefaultScript;
       SyntaxTree syntaxTree = SyntaxTree.ParseText(code, path, options, new CancellationToken());
       diagnostics.Add((IEnumerable<CommonDiagnostic>) syntaxTree.GetDiagnostics(new CancellationToken()));
       if (diagnostics.HasAnyErrors())
     return (CommonCompilation) null;
       string assemblyName;
       string typeName;
       this.GenerateSubmissionId(out assemblyName, out typeName);
       Compilation submission = Compilation.CreateSubmission(assemblyName, new CompilationOptions(OutputKind.DynamicallyLinkedLibrary, (string) null, typeName, (IEnumerable<string>) namespacesForCompilation.ToList(), DebugInformationKind.None, false, true, false, true, (string) null, (string) null, new bool?(), 0, 0UL, Platform.AnyCPU, ReportWarning.Default, 4, (IReadOnlyDictionary<int, ReportWarning>) null, false, new SubsystemVersion()), syntaxTree, previousSubmission, referencesForCompilation, session.FileResolver, this.metadataFileProvider, returnType, session.HostObjectType);
       this.ValidateReferences((CommonCompilation) submission, diagnostics);
       if (diagnostics.HasAnyErrors())
     return (CommonCompilation) null;
       else
     return (CommonCompilation) submission;
 }
Exemple #30
0
        public static CompilationUnitSyntax Apply(IText text, TextSpan span, out IEnumerable<SyntaxAnnotation> propertyAnnotations)
        {
            var document = GetDocument(text);
            document = PropertyAnnotater.Annotate(document, span, out propertyAnnotations);

            foreach (var propertyAnnotation in propertyAnnotations)
            {
                var propertyDeclaration = document.GetAnnotatedNode<PropertyDeclarationSyntax>(propertyAnnotation);
                document = document.ExpandProperty(propertyDeclaration);

                propertyDeclaration = document.GetAnnotatedNode<PropertyDeclarationSyntax>(propertyAnnotation);
                var classDeclaration = propertyDeclaration.FirstAncestorOrSelf<ClassDeclarationSyntax>();
                document = document.ImplementINotifyPropertyChanged(classDeclaration);
            }

            var newRoot = document
                .Simplify(CodeAnnotations.Simplify)
                .Format(CodeAnnotations.Formatting)
                .GetSyntaxRoot();

            return (CompilationUnitSyntax)newRoot;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TextsController"/> class.
 /// </summary>
 /// <param name="text">A service with access to text resources.</param>
 public TextsController(IText text)
 {
     _text = text;
 }
Exemple #32
0
 public Slash(IText text)
 {
     _text = text;
 }
Exemple #33
0
 internal TestableResourceHandler(AppConfig appConfig, BrowserSettings settings, IRequestFilter filter, ILogger logger, IText text) : base(appConfig, settings, filter, logger, text)
 {
 }
Exemple #34
0
 /// <summary>
 /// Initializes a new instance of <see cref="InferredName"/>.
 /// </summary>
 /// <param name="typeCache">Type cache without namespaces.</param>
 /// <param name="source">The name to infer.</param>
 /// <param name="handleDuplicatesIndex">If there are duplicate type names in an assembly, this index used to access a particular item from an array.</param>
 public InferredName(IScalar <IReadOnlyDictionary <string, Type[]> > typeCache, IText source, int handleDuplicatesIndex = 0)
 {
     _handleDuplicatesIndex     = handleDuplicatesIndex;
     _typeCacheWithoutNamespace = new Cached <IReadOnlyDictionary <string, Type[]> >(typeCache);
     _source = source;
 }
Exemple #35
0
 public static void MapText(IButtonHandler handler, IText button)
 {
     handler.TypedNativeView?.UpdateTextPlainText(button);
 }
Exemple #36
0
        public ItemColor GetForeground(IText text)
        {
            var tb = WpfBlockHelper.GetTextBlock(text);

            return(GetItemColor(tb.Foreground));
        }
 public void VisitText(IText text)
 {
     Count += text.Properties.Text.Length;
 }
Exemple #38
0
 public void Deselect(IText text)
 {
     WpfBlockHelper.GetTextBlock(text).Foreground = WpfBlockFactory.NormalBrush;
 }
Exemple #39
0
 public void Select(IText text)
 {
     WpfBlockHelper.GetTextBlock(text).Foreground = WpfBlockFactory.SelectedBrush;
 }
Exemple #40
0
        public bool IsSelected(IText text)
        {
            var tb = WpfBlockHelper.GetTextBlock(text);

            return(tb.Foreground != WpfBlockFactory.SelectedBrush);
        }
Exemple #41
0
 public static TextBlock GetTextBlock(IText text)
 {
     return((text.Native as Grid).Children[0] as TextBlock);
 }
        internal override CommonCompilation CreateCompilation(IText code, string path, bool isInteractive, Session session, Type returnType, DiagnosticBag diagnostics)
        {
            Debug.Assert(code != null && path != null && diagnostics != null);

            Compilation previousSubmission = (session != null) ? (Compilation)session.LastSubmission : null;

            IEnumerable <MetadataReference> references = GetReferences(session);
            ReadOnlyArray <string>          usings     = GetImportedNamespaces(session);

            // TODO (tomat): BaseDirectory should be a property on ScriptEngine?
            var fileResolver = Session.GetFileResolver(session, Directory.GetCurrentDirectory());

            // parse:
            var parseOptions = isInteractive ? DefaultInteractive : DefaultScript;
            var tree         = SyntaxTree.ParseText(code, path, parseOptions);

            diagnostics.Add(tree.GetDiagnostics());
            if (diagnostics.HasAnyErrors())
            {
                return(null);
            }

            // create compilation:
            string assemblyName, submissionTypeName;

            GenerateSubmissionId(out assemblyName, out submissionTypeName);

            var compilation = Compilation.CreateSubmission(
                assemblyName,
                new CompilationOptions(
                    outputKind: OutputKind.DynamicallyLinkedLibrary,
                    mainTypeName: null,
                    scriptClassName: submissionTypeName,
                    usings: usings.ToList(),
                    optimize: false,                    // TODO (tomat)
                    checkOverflow: true,                // TODO (tomat)
                    allowUnsafe: false,                 // TODO (tomat)
                    cryptoKeyContainer: null,
                    cryptoKeyFile: null,
                    delaySign: null,
                    fileAlignment: 0,
                    baseAddress: 0L,
                    platform: Platform.AnyCPU,
                    generalWarningOption: ReportWarning.Default,
                    warningLevel: 4,
                    specificWarningOptions: null,
                    highEntropyVirtualAddressSpace: false
                    ),
                tree,
                previousSubmission,
                references,
                fileResolver,
                this.metadataFileProvider,
                returnType,
                (session != null) ? session.HostObjectType : null
                );

            ValidateReferences(compilation, diagnostics);
            if (diagnostics.HasAnyErrors())
            {
                return(null);
            }

            return(compilation);
        }
 public I18nOperation(ILogger logger, IText text)
 {
     this.logger = logger;
     this.text   = text;
 }
        private void RecursionHtmlNode(string treeNode, INode htmlNode, bool siblingRequired)
        {
            if (htmlNode == null || treeNode == null)
            {
                return;
            }

            string current = treeNode;

            //string content;
            //current node
            if (htmlNode is ITag)
            {
                string nodeString = "";
                ITag   tag        = (htmlNode as ITag);
                if (!tag.IsEndTag())
                {
                    nodeString = tag.TagName;
                    if (tag.Attributes != null && tag.Attributes.Count > 0)
                    {
                        if (tag.Attributes["ID"] != null)
                        {
                            nodeString = nodeString + " { id=\"" + tag.Attributes["ID"].ToString() + "\" }";
                        }
                        if (tag.Attributes["HREF"] != null)
                        {
                            nodeString = nodeString + " { href=\"" + tag.Attributes["HREF"].ToString() + "\" }";
                        }
                        if (tag.Attributes["SIZE"] != null)
                        {
                            nodeString = nodeString + " { size=\"" + tag.Attributes["SIZE"].ToString() + "\" }";
                        }
                        if (tag.Attributes["COLOR"] != null)
                        {
                            nodeString = nodeString + " { color=\"" + tag.Attributes["COLOR"].ToString() + "\" }";
                        }
                    }
                }
                else
                {
                    nodeString = tag.TagName + " End";
                }
                current = nodeString;
                节点列表.Add(current);
            }
            //获取节点间的内容
            if (htmlNode.Children != null && htmlNode.Children.Count > 0)
            {
                this.RecursionHtmlNode(current, htmlNode.FirstChild, true);
                //content = htmlNode.FirstChild.GetText();
                //节点列表.Add(content);
            }
            else if (!(htmlNode is ITag))
            {
                if (htmlNode is IText)
                {
                    IText tex = htmlNode as IText;
                    current = tex.GetText();
                    current = current.Replace("\r\n", "");
                    current = current.Replace("&nbsp;", " ");
                    byte[] utf8Bom = new byte[] { 239, 187, 191 };
                    current = current.Replace(PlatformTools.BS2String_UTF8(utf8Bom), "");
                    bool allIsSpace = true;
                    for (int i = 0; i < current.Length; ++i)
                    {
                        if (current[i] != ' ')
                        {
                            allIsSpace = false;
                            break;
                        }
                    }
                    if (!string.IsNullOrEmpty(current) && current != "\t" && !allIsSpace)
                    {
                        节点列表.Add(current);
                    }
                }
                else
                {
                    string typestr = htmlNode.GetType().ToString();
                    节点列表.Add(typestr);
                }
            }

            //the sibling nodes
            if (siblingRequired)
            {
                INode sibling = htmlNode.NextSibling;
                while (sibling != null)
                {
                    this.RecursionHtmlNode(treeNode, sibling, false);
                    sibling = sibling.NextSibling;
                }
            }
        }
Exemple #45
0
 public ReplacedText(IText source, char old, char replace)
 {
     this.source  = source;
     this.old     = old;
     this.replace = replace;
 }
 protected void AddText(IText text)
 {
     _texts[text.Id] = text;
 }
Exemple #47
0
 public BadCredentialViewModel(IText message)
 {
     Message = message.String();
 }
 public bool TryGetText(string id, out IText text)
 {
     return(_texts.TryGetValue(id, out text));
 }
        public TextManager(IText editor)

        {
            this.editor = editor;
        }
Exemple #50
0
 public static void UpdateFont(this TextBox platformControl, IText text, IFontManager fontManager) =>
 platformControl.UpdateFont(text.Font, fontManager);
Exemple #51
0
 public void VisitText(IText text)
 {
     PlainText += text.ToString();
 }
Exemple #52
0
 public void VisitText(IText text)
 {
     //Nothing to add
 }
Exemple #53
0
 /// <summary>
 /// Ctor.
 /// </summary>
 public Subtitle(IText text)
 {
     this.childs.Add(text);
 }
Exemple #54
0
 internal static void UpdateTextPlainText(this UILabel platformLabel, IText label)
 {
     platformLabel.Text = label.Text;
 }
Exemple #55
0
 public HoverTextEvent(IText source)
 {
     Source = source;
 }
 public MessageBoxFactory(IText text)
 {
     this.text = text;
 }
Exemple #57
0
        public string GetText(IText text)
        {
            var tb = WpfBlockHelper.GetTextBlock(text);

            return(tb.Text);
        }
Exemple #58
0
 /// <summary>
 /// Adds a body to a request
 /// </summary>
 public Body(IText text) : this(
         new BytesOf(text)
         )
 {
 }
Exemple #59
0
 /// <summary>
 /// Adds a body and its content type to a request.
 /// </summary>
 public Body(IText content, string contentType) : this(
         new BytesOf(content),
         contentType
         )
 {
 }
Exemple #60
0
        public void VisitText(IText text)
        {
            var txt = text.Properties.Text;

            textList.Add(new Tuple <string, IText>(txt, text));
        }