Esempio n. 1
0
        private IGlyphTransformationTable ParseCoverageChainingSubstitutionTable(int subTableOffset, dynamic fontTable, LookupFlags lookupFlags)
        {
            var     type  = typeof(GlyphTypeface).Assembly.GetType("MS.Internal.Shaping.CoverageChainingSubtable");
            dynamic table = new AccessPrivateWrapper(TypeExtensions.Instantiate(type, fontTable.Wrapped, subTableOffset));

            dynamic contextualLookupTable = new AccessPrivateWrapper(table.ContextualLookups(fontTable.Wrapped));

            return(new ChainingCoverageContextSubstitutionTable
            {
                LookbackCoverages = this.GetEnumerableFromInternalList(
                    () => table.BacktrackGlyphCount(fontTable.Wrapped),
                    i => (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.BacktrackCoverage(fontTable.Wrapped, i)))).ToList(),
                ContextCoverages = this.GetEnumerableFromInternalList(
                    () => table.InputGlyphCount(fontTable.Wrapped),
                    i => (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.InputCoverage(fontTable.Wrapped, i)))).ToList(),
                LookaheadCoverages = this.GetEnumerableFromInternalList(
                    () => table.LookaheadGlyphCount(fontTable.Wrapped),
                    i => (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.LookaheadCoverage(fontTable.Wrapped, i)))).ToList(),
                TransformationSets = this.GetEnumerableFromInternalList(
                    () => contextualLookupTable.recordCount,
                    i => new ContextTransformationSet
                {
                    FirstGlyphIndex = contextualLookupTable.SequenceIndex(fontTable.Wrapped, i),
                    Transformations = this.GetTransformationTablesByLookupIndex(fontTable, contextualLookupTable.LookupIndex(fontTable.Wrapped, i))
                }).ToList(),
                LookupFlags = lookupFlags
            });
        }
Esempio n. 2
0
        public override void ShowInExplorer(string serverItem)
        {
            if (!String.IsNullOrEmpty(serverItem))
            {
                Assembly tfsVC = TfsVersionControlAssembly;

                // if the tool window hasn't been opened yet "explorer" will be null, so we make sure it has opened at least once via ExecuteCommand
                DTEInstance.ExecuteCommand("View.TfsSourceControlExplorer");
                Type explorer = tfsVC.GetType("Microsoft.VisualStudio.TeamFoundation.VersionControl.ToolWindowSccExplorer");

                var    prop = explorer.GetProperty("Instance", BindingFlags.NonPublic | BindingFlags.Static);
                object toolWindowSccExplorerInstance = prop.GetValue(null, null);
                if (toolWindowSccExplorerInstance != null)
                {
                    var navMethod = toolWindowSccExplorerInstance.GetType().GetMethod("Navigate", BindingFlags.Default | BindingFlags.Instance | BindingFlags.NonPublic);
                    if (navMethod != null)
                    {
                        navMethod.Invoke(toolWindowSccExplorerInstance, new object[] { serverItem });
                        dynamic dynEx = new AccessPrivateWrapper(toolWindowSccExplorerInstance);
                        dynamic x2    = new AccessPrivateWrapper(dynEx.SccExplorer);
                        DispatchScrollToSccExplorerSelection(ScrollToDispatchLagTime, x2);
                    }
                }
            }
        }
Esempio n. 3
0
        private IGlyphTransformationTable ParseGlyphChainingSubstitutionTable(int subTableOffset, dynamic fontTable, LookupFlags lookupFlags)
        {
            var     type  = typeof(GlyphTypeface).Assembly.GetType("MS.Internal.Shaping.GlyphChainingSubtable");
            dynamic table = new AccessPrivateWrapper(type.Instantiate(subTableOffset));

            var coverageTable = (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.Coverage(fontTable.Wrapped)));

            var ruleSetTables = this.GetEnumerableFromInternalList(
                () => (ushort)coverageTable.CoveredGlyphIds.Count(),
                i => (dynamic) new AccessPrivateWrapper(table.RuleSet(fontTable.Wrapped, i))).ToList();

            return(new ChainingGlyphContextTransformationTable
            {
                Coverage = coverageTable,
                TransformationRules = ruleSetTables
                                      .Select(
                    ruleSetTable => this.GetEnumerableFromInternalList(
                        () => ruleSetTable.RuleCount(fontTable.Wrapped),
                        i => (ChainingContextTransformationRule)this.ParseChainingTransformationRule(
                            fontTable,
                            new AccessPrivateWrapper(table.Rule(fontTable.Wrapped, i)),
                            (Func <dynamic, int, ushort>)((ruleTable, index) => (ushort)ruleTable.GlyphId(fontTable.Wrapped, index)),
                            coverageTable.CoveredGlyphIds[i])).ToList()).ToList(),
                LookupFlags = lookupFlags
            });
        }
Esempio n. 4
0
        private IGlyphTransformationTable ParseMultipleSubstitutionTable(int subTableOffset, dynamic fontTable, LookupFlags lookupFlags)
        {
            var     type   = typeof(GlyphTypeface).Assembly.GetType("MS.Internal.Shaping.MultipleSubstitutionSubtable");
            dynamic table  = new AccessPrivateWrapper(type.Instantiate(subTableOffset));
            ushort  format = table.Format(fontTable.Wrapped);

            if (format != 1)
            {
                throw new UnknownTableFormatException(type, format);
            }

            var coverageTable = this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.Coverage(fontTable.Wrapped)));

            var substitutionSequenceTables = this.GetEnumerableFromInternalList(
                () => (ushort)coverageTable.CoveredGlyphIds.Count, i => (dynamic) new AccessPrivateWrapper(table.Sequence(fontTable.Wrapped, i))).ToList();

            var sequences = substitutionSequenceTables
                            .Select(
                sequenceTable =>
                this.GetEnumerableFromInternalList(
                    () => sequenceTable.GlyphCount(fontTable.Wrapped),
                    i => (ushort)sequenceTable.Glyph(fontTable.Wrapped, i))).ToList();

            return(new MultipleSubstitutionTable
            {
                Coverage = this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.Coverage(fontTable.Wrapped))),
                ReplacementSequences = sequences.ToList(),
                LookupFlags = lookupFlags
            });
        }
Esempio n. 5
0
        private IGlyphTransformationTable ParseSingleSubstitutionTable(int subTableOffset, dynamic fontTable, LookupFlags lookupFlags)
        {
            var     type   = typeof(GlyphTypeface).Assembly.GetType("MS.Internal.Shaping.SingleSubstitutionSubtable");
            dynamic table  = new AccessPrivateWrapper(type.Instantiate(subTableOffset));
            ushort  format = table.Format(fontTable.Wrapped);

            switch (format)
            {
            case 1:
                return(new DeltaSubstitutionTable
                {
                    Coverage = this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.Coverage(fontTable.Wrapped))),
                    GlyphIdDelta = (short)table.Format1DeltaGlyphId(fontTable.Wrapped),
                    LookupFlags = lookupFlags
                });

            case 2:
                var coverage = (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.Coverage(fontTable.Wrapped)));
                return(new SimpleReplacementSubstitutionTable
                {
                    Coverage = coverage,
                    ReplacementGlyphIds =
                        coverage.CoveredGlyphIds.Keys
                        .Select(coverageIndex => (ushort)table.Format2SubstituteGlyphId(fontTable.Wrapped, coverageIndex)).ToList(),
                    LookupFlags = lookupFlags
                });

            default:
                throw new UnknownTableFormatException(type, format);
            }
        }
        private static sbyte ToPixels(double designSize, double emSize, GlyphTypeface typeface)
        {
            dynamic typefaceFriend = new AccessPrivateWrapper(typeface);
            ushort  designEmHeight = typefaceFriend.DesignEmHeight;

            return((sbyte)(designSize / designEmHeight * (emSize * 96.0 / 72.0)));
        }
Esempio n. 7
0
        private IGlyphTransformationTable ParseCursivePositioningTable(int subTableOffset, dynamic fontTable, LookupFlags lookupFlags)
        {
            var     type   = typeof(GlyphTypeface).Assembly.GetType("MS.Internal.Shaping.CursivePositioningSubtable");
            dynamic table  = new AccessPrivateWrapper(type.Instantiate(subTableOffset));
            ushort  format = table.Format(fontTable.Wrapped);

            if (format != 1)
            {
                throw new UnknownTableFormatException(type, format);
            }

            var coverage          = (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.Coverage(fontTable.Wrapped)));
            var coveredGlyphCount = coverage.CoveredGlyphIds.Count();

            return(new CursivePositioningTable
            {
                Coverage = coverage,
                EntryExitRecords =
                    this.GetEnumerableFromInternalList(
                        () => (ushort)coveredGlyphCount,
                        i => Tuple.Create(
                            (AnchorPoint)this.ParseAnchor(fontTable, new AccessPrivateWrapper(table.EntryAnchor(fontTable.Wrapped, i))),
                            (AnchorPoint)this.ParseAnchor(fontTable, new AccessPrivateWrapper(table.ExitAnchor(fontTable.Wrapped, i)))
                            )).ToList(),
                LookupFlags = lookupFlags
            });
        }
Esempio n. 8
0
        private IGlyphTransformationTable ParseMarkToBasePositioningTable(int subTableOffset, dynamic fontTable, LookupFlags lookupFlags)
        {
            var     type   = typeof(GlyphTypeface).Assembly.GetType("MS.Internal.Shaping.MarkToBasePositioningSubtable");
            dynamic table  = new AccessPrivateWrapper(type.Instantiate(subTableOffset));
            ushort  format = table.Format(fontTable.Wrapped);

            if (format != 1)
            {
                throw new UnknownTableFormatException(type, format);
            }

            dynamic markArrayTable = new AccessPrivateWrapper(table.Marks(fontTable.Wrapped));
            dynamic baseArrayTable = new AccessPrivateWrapper(table.Bases(fontTable.Wrapped));

            return(new MarkToBasePositioningTable
            {
                MarkCoverage = (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.MarkCoverage(fontTable.Wrapped))),
                BaseCoverage = (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.BaseCoverage(fontTable.Wrapped))),
                MarkAnchorPoints = this.GetEnumerableFromInternalList(
                    () => fontTable.GetUShort(markArrayTable.offset),
                    i =>
                    new Tuple <ushort, AnchorPoint>(
                        (ushort)markArrayTable.Class(fontTable.Wrapped, i),
                        (AnchorPoint)this.ParseAnchor(fontTable, new AccessPrivateWrapper(markArrayTable.MarkAnchor(fontTable.Wrapped, i)))
                        )).ToList(),
                BaseAnchorPoints = this.GetEnumerableFromInternalList(
                    () => fontTable.GetUShort(baseArrayTable.offset),
                    i => this.GetEnumerableFromInternalList(
                        () => table.ClassCount(fontTable.Wrapped),
                        j => (AnchorPoint)this.ParseAnchor(fontTable, new AccessPrivateWrapper(baseArrayTable.BaseAnchor(fontTable.Wrapped, i, table.ClassCount(fontTable.Wrapped), j)))
                        ).ToList()
                    ).ToList(),
                LookupFlags = lookupFlags
            });
        }
Esempio n. 9
0
        /// <summary>
        /// Gets a collection of all language systems supported by a single script the typeface. List of all known lang sys tags can be found here: http://www.microsoft.com/typography/developers/opentype/languagetags.aspx .
        /// </summary>
        /// <param name="typeface">The typeface.</param>
        /// <param name="script">The script tag.</param>
        /// <returns>
        /// Collection of tags.
        /// </returns>
        public IEnumerable <Tag> GetLangSysTags(GlyphTypeface typeface, Tag script)
        {
            dynamic fontTableHeader = this.GetFontTableHeader();
            dynamic fontTable       = this.GetFontTable(typeface);

            if (!fontTable.IsPresent)
            {
                yield break;
            }

            dynamic scriptList  = new AccessPrivateWrapper(fontTableHeader.GetScriptList(fontTable.Wrapped));
            dynamic scriptTable = new AccessPrivateWrapper(scriptList.FindScript(fontTable.Wrapped, TagConverter.UintFromTag(script)));

            if (scriptTable.IsNull)
            {
                throw new ArgumentOutOfRangeException("script");
            }

            if (scriptTable.IsDefaultLangSysExists(fontTable.Wrapped))
            {
                yield return(new Tag("dflt"));
            }

            var uintTags = this.GetEnumerableFromInternalList(
                () => scriptTable.GetLangSysCount(fontTable.Wrapped),
                p => (uint)scriptTable.GetLangSysTag(fontTable.Wrapped, p));

            foreach (var uintTag in uintTags)
            {
                yield return(TagConverter.TagFromUint(uintTag));
            }
        }
Esempio n. 10
0
        private IGlyphTransformationTable ParseSinglePositioningTable(int subTableOffset, dynamic fontTable, LookupFlags lookupFlags)
        {
            var     type  = typeof(GlyphTypeface).Assembly.GetType("MS.Internal.Shaping.SinglePositioningSubtable");
            dynamic table = new AccessPrivateWrapper(type.Instantiate(subTableOffset));

            ushort format = table.Format(fontTable.Wrapped);

            switch (format)
            {
            case 1:
                return(new ConstantPositioningTable
                {
                    Coverage = this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.Coverage(fontTable.Wrapped))),
                    PositionChange = this.ParseValueRecord(fontTable, new AccessPrivateWrapper(table.Format1ValueRecord(fontTable.Wrapped))),
                    LookupFlags = lookupFlags
                });

            case 2:
                var coverage = (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.Coverage(fontTable.Wrapped)));
                return(new IndividualChangePositioningTable
                {
                    Coverage = coverage,
                    PositionChanges =
                        coverage.CoveredGlyphIds.Keys
                        .Select(coverageIndex => (GlyphPositionChange)this.ParseValueRecord(fontTable, new AccessPrivateWrapper(table.Format2ValueRecord(fontTable.Wrapped, coverageIndex)))).ToList(),
                    LookupFlags = lookupFlags
                });

            default:
                throw new UnknownTableFormatException(type, format);
            }
        }
Esempio n. 11
0
        private IGlyphTransformationTable ParseClassContextSubstitutionTable(int subTableOffset, dynamic fontTable, LookupFlags lookupFlags)
        {
            var     type  = typeof(GlyphTypeface).Assembly.GetType("MS.Internal.Shaping.ClassContextSubtable");
            dynamic table = new AccessPrivateWrapper(type.Instantiate(subTableOffset));

            var coverageTable = this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.Coverage(fontTable.Wrapped)));

            var ruleSetTables = this.GetEnumerableFromInternalList(
                () => (ushort)table.ClassSetCount(fontTable.Wrapped),
                i => (dynamic) new AccessPrivateWrapper(table.ClassSet(fontTable.Wrapped, i))).ToList();

            return(new ClassContextTransformationTable
            {
                Coverage = coverageTable,
                ClassDefinitions = this.ParseClassDef(fontTable, new AccessPrivateWrapper(table.ClassDef(fontTable.Wrapped))),
                TransformationRules = ruleSetTables
                                      .Select(
                    ruleSetTable =>
                    ruleSetTable.IsNull ?
                    Enumerable.Empty <ContextTransformationRule>() :
                    this.GetEnumerableFromInternalList(
                        () => ruleSetTable.RuleCount(fontTable.Wrapped),
                        i => (ContextTransformationRule)this.ParseContextTransformationRule(
                            fontTable,
                            new AccessPrivateWrapper(ruleSetTable.Rule(fontTable.Wrapped, i)),
                            (Func <dynamic, int, ushort>)((ruleTable, index) => (ushort)ruleTable.ClassId(fontTable.Wrapped, index)))).ToList()).ToList(),
                LookupFlags = lookupFlags
            });
        }
        public object GetSourceControlExplorer()
        {
            dynamic sccToolWindow = new AccessPrivateWrapper(wrapped.GetToolWindowSccExplorer(true));
            dynamic explorer      = new AccessPrivateWrapper(sccToolWindow.SccExplorer);

            return(explorer);
        }
Esempio n. 13
0
        virtual public void DispatchOpenSceToPath(string serverPath, object workspace)
        {
            /* In VS2013 (unlike VS2010) the Source Control Explorer opens asynchronously. This caused an issue that when
             * the SCE was not open and "Locate in TFS" was clicked we would not be able to open the SCE to the correct place
             * because it hadn't finished opening and connecting.
             *
             * There aren't any obvious events to which to subscribe, thus we do some polling in a separate thread via
             * the Dispatcher. It has to be a separate thread in order to not block the SCE from loading.
             * */

            // This will make sure the SCE window is open, or will open
            dynamic sccToolWindow = new AccessPrivateWrapper(HatterasPackage._wrapped.GetToolWindowSccExplorer(true));
            dynamic explorer      = new AccessPrivateWrapper(sccToolWindow.SccExplorer);

            // We don't want to loop infinitely, if we've tried a few times and it's still not connected then just give up
            // By default this will be about five seconds (10 attempts, 0.5 seconds interval)
            var poller = new DispatchedPoller(MaxDispatchAttempts, DispatchPollTime, () =>
            {
                return(!explorer.IsDisconnected);
            },
                                              () =>
            {
                // The explorer is connected, so we're ready to go
                OpenSceToPathWithPrecedingCall(serverPath, workspace, explorer);
            });

            poller.Go();
        }
Esempio n. 14
0
 public TFSVersionControl(ITFSConnection _tfsConnection, EnvDTE80.DTE2 _dte, ILogger _logger)
 {
     dte           = _dte;
     logger        = _logger;
     tfsConnection = _tfsConnection;
     tfsConnection.ConnectionChanged += ResetConnection;
     versionControlControlsAssembly   = Assembly.Load(versionControlControlsAssemblyString);
     folderDiffOptions = AccessPrivateWrapper.FromType(versionControlControlsAssembly, BindingFlags.NonPublic | BindingFlags.Instance, "FolderDiffOptions");
 }
Esempio n. 15
0
        private IEnumerable <IGlyphTransformationTable> GetTransformationTablesByLookupIndex(dynamic fontTable, ushort lookupIndex)
        {
            dynamic fontTableHeader = this.GetFontTableHeader();
            dynamic lookupList      = new AccessPrivateWrapper(fontTableHeader.GetLookupList(fontTable.Wrapped));

            dynamic lookupTable = new AccessPrivateWrapper(lookupList.Lookup(fontTable.Wrapped, lookupIndex));

            return(this.GetSubstitutionTablesByLookupTable(fontTable, lookupTable));
        }
Esempio n. 16
0
        private ChainingContextTransformationRule ParseChainingTransformationRule(dynamic fontTable, dynamic rule, Func <dynamic, int, ushort> idProjection, ushort firstInputId)
        {
            const int GlyphIdSize = 2;

            // Load the lookback
            var lookBackCount = rule.GlyphCount(fontTable.Wrapped, rule.offset);
            int currentOffset = rule.offset + rule.sizeCount;

            var lookBackGlyphIds = this.GetEnumerableFromInternalList(
                () => lookBackCount,
                i => (ushort)idProjection(rule, (i * GlyphIdSize) + currentOffset)).ToList();

            currentOffset += lookBackCount * GlyphIdSize;

            // Load the context
            var contextCount = rule.GlyphCount(fontTable.Wrapped, currentOffset);

            currentOffset += rule.sizeCount;

            // The first element of the context comes from index of the rule set
            var contextGlyphIds = this.GetEnumerableFromInternalList(
                () => (ushort)(contextCount - 1),
                i => (ushort)idProjection(rule, (i * GlyphIdSize) + currentOffset)).Prepend(firstInputId).ToList();

            currentOffset += (contextCount - 1) * GlyphIdSize;

            // Load the context
            var lookAheadCount = rule.GlyphCount(fontTable.Wrapped, currentOffset);

            currentOffset += rule.sizeCount;

            var lookAheadGlyphIds = this.GetEnumerableFromInternalList(
                () => lookAheadCount,
                i => (ushort)idProjection(rule, (i * GlyphIdSize) + currentOffset)).ToList();

            currentOffset += lookAheadCount * GlyphIdSize;

            // Load the substitution lookup records
            var lookupSubstitutionRecordCount = fontTable.GetUShort(currentOffset);

            dynamic contextualLookupsTable = new AccessPrivateWrapper(rule.ContextualLookups(fontTable.Wrapped, currentOffset));

            return(new ChainingContextTransformationRule
            {
                Lookback = lookBackGlyphIds,
                Context = contextGlyphIds,
                Lookahead = lookAheadGlyphIds,
                TransformationSets = this.GetEnumerableFromInternalList(
                    () => lookupSubstitutionRecordCount,
                    i => new ContextTransformationSet
                {
                    FirstGlyphIndex = contextualLookupsTable.SequenceIndex(fontTable.Wrapped, i),
                    Transformations = this.GetTransformationTablesByLookupIndex(fontTable, contextualLookupsTable.LookupIndex(fontTable.Wrapped, i))
                }).ToList()
            });
        }
Esempio n. 17
0
        protected IGlyphTransformationTable ParseExtensionLookupTable(int subTableOffset, dynamic fontTable, LookupFlags lookupFlags)
        {
            var     type  = typeof(GlyphTypeface).Assembly.GetType("MS.Internal.Shaping.ExtensionLookupTable");
            dynamic table = new AccessPrivateWrapper(type.Instantiate(subTableOffset));

            var lookupType   = (int)table.LookupType(fontTable.Wrapped);
            var lookupOffset = (int)table.LookupSubtableOffset(fontTable.Wrapped);

            return(this.GetSubstitutionTableBySubTableOffset(fontTable, lookupOffset, lookupType, lookupFlags));
        }
Esempio n. 18
0
        public void OnceUnitOpened_TransactionPropertyIsPopulated()
        {
            //Arrange
            var setup = new NhibernateTestSetupHelper();

            using (var writer = setup.ProviderSetup.UnitFactory.Create())
            {
                dynamic access = new AccessPrivateWrapper(writer.EntityRepository.Transaction);
                Assert.NotNull(access._nhTransaction);
            }
        }
Esempio n. 19
0
        protected override dynamic GetFontTable(GlyphTypeface typeface)
        {
            var fontTableType = typeof(GlyphTypeface).Assembly.GetType("MS.Internal.Shaping.FontTable");

            dynamic font       = this.GetOpenTypeFont(typeface);
            dynamic layoutInfo = new AccessPrivateWrapper(font._layout);

            byte[] fontTableBytes = layoutInfo.Gdef();

            return(Activator.CreateInstance(fontTableType, fontTableBytes).AccessNonPublic());
        }
Esempio n. 20
0
        private IGlyphTransformationTable ParsePairPositioningTable(int subTableOffset, dynamic fontTable, LookupFlags lookupFlags)
        {
            var     type   = typeof(GlyphTypeface).Assembly.GetType("MS.Internal.Shaping.PairPositioningSubtable");
            dynamic table  = new AccessPrivateWrapper(type.Instantiate(subTableOffset));
            ushort  format = table.Format(fontTable.Wrapped);

            var coverage          = (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.Coverage(fontTable.Wrapped)));
            var coveredGlyphCount = coverage.CoveredGlyphIds.Count();

            switch (format)
            {
            case 1:
                var pairSetTables = this.GetEnumerableFromInternalList(
                    () => (ushort)coveredGlyphCount,
                    i => (dynamic) new AccessPrivateWrapper(table.Format1PairSet(fontTable.Wrapped, i))).ToList();

                return(new GlyphPairPositioningTable
                {
                    Coverage = coverage,
                    PairSets =
                        pairSetTables.Select(pairSet => this.GetEnumerableFromInternalList(
                                                 () => (ushort)pairSet.PairValueCount(fontTable.Wrapped),
                                                 i => new PositioningPair
                    {
                        SecondGlyphID = (ushort)pairSet.PairValueGlyph(fontTable.Wrapped, i),
                        FirstGlyphPositionChange = this.ParseValueRecord(fontTable, new AccessPrivateWrapper(pairSet.FirstValueRecord(fontTable.Wrapped, i, table.FirstValueFormat(fontTable.Wrapped)))),
                        SecondGlyphPositionChange = this.ParseValueRecord(fontTable, new AccessPrivateWrapper(pairSet.SecondValueRecord(fontTable.Wrapped, i, table.SecondValueFormat(fontTable.Wrapped)))),
                    }).ToList()).ToList(),
                    LookupFlags = lookupFlags
                });

            case 2:
                var class2Count = (ushort)table.Format2Class2Count(fontTable.Wrapped);

                return(new ClassPairPositioningTable
                {
                    Coverage = coverage,
                    FirstClassDef = this.ParseClassDef(fontTable, new AccessPrivateWrapper(table.Format2Class1Table(fontTable.Wrapped))),
                    SecondClassDef = this.ParseClassDef(fontTable, new AccessPrivateWrapper(table.Format2Class2Table(fontTable.Wrapped))),
                    PairSets =
                        (from i in Enumerable.Range(0, (ushort)table.Format2Class1Count(fontTable.Wrapped))
                         select
                             (from j in Enumerable.Range(0, class2Count)
                             select Tuple.Create(
                                 (GlyphPositionChange)this.ParseValueRecord(fontTable, new AccessPrivateWrapper(table.Format2FirstValueRecord(fontTable.Wrapped, class2Count, (ushort)i, (ushort)j))),
                                 (GlyphPositionChange)this.ParseValueRecord(fontTable, new AccessPrivateWrapper(table.Format2SecondValueRecord(fontTable.Wrapped, class2Count, (ushort)i, (ushort)j)))
                                 )).ToList()).ToList(),
                    LookupFlags = lookupFlags
                });

            default:
                throw new UnknownTableFormatException(type, format);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Gets collection of all features supported by the typeface.
        /// </summary>
        /// <param name="typeface">The typeface.</param>
        /// <returns>Collection of tags.</returns>
        public IEnumerable <Tag> GetAllFeatureTags(GlyphTypeface typeface)
        {
            dynamic fontTable       = this.GetFontTable(typeface);
            dynamic fontTableHeader = this.GetFontTableHeader();
            dynamic featureList     = new AccessPrivateWrapper(fontTableHeader.GetFeatureList(fontTable.Wrapped));

            var uintTags = this.GetEnumerableFromInternalList(
                () => featureList.FeatureCount(fontTable.Wrapped),
                p => (uint)featureList.FeatureTag(fontTable.Wrapped, p));

            return(uintTags.Select(TagConverter.TagFromUint));
        }
Esempio n. 22
0
        private IGlyphTransformationTable ParseReverseChainingSubstitutionTable(int subTableOffset, dynamic fontTable, LookupFlags lookupFlags)
        {
            var     type   = typeof(GlyphTypeface).Assembly.GetType("MS.Internal.Shaping.ReverseChainingSubtable");
            dynamic table  = new AccessPrivateWrapper(type.Instantiate(subTableOffset));
            ushort  format = table.Format(fontTable.Wrapped);

            if (format != 1)
            {
                throw new UnknownTableFormatException(type, format);
            }

            var result = new ReverseChainingContextSubstitutionTable
            {
                Coverage = this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.InputCoverage(fontTable.Wrapped)))
            };

            int currentOffset = table.offset + table.offsetBacktrackGlyphCount;

            ushort lookbackCount = table.GlyphCount(fontTable.Wrapped, currentOffset);

            currentOffset += 2;

            result.LookbackCoverages = this.GetEnumerableFromInternalList(
                () => lookbackCount,
                i => (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.Coverage(fontTable.Wrapped, currentOffset)))
                ).ToList();

            currentOffset += 2 * lookbackCount;

            ushort lookaheadCount = table.GlyphCount(fontTable.Wrapped, currentOffset);

            currentOffset += 2;

            result.LookaheadCoverages = this.GetEnumerableFromInternalList(
                () => lookaheadCount,
                i => (ICoverageTable)this.ParseCoverageTable(fontTable, new AccessPrivateWrapper(table.Coverage(fontTable.Wrapped, currentOffset)))
                ).ToList();

            currentOffset += 2 * lookaheadCount;

            ushort glyphCount = table.GlyphCount(fontTable.Wrapped, currentOffset);

            currentOffset += 2;

            result.SubstituteGlyphIds = this.GetEnumerableFromInternalList(
                () => glyphCount,
                i => (ushort)table.Glyph(fontTable.Wrapped, currentOffset)
                ).ToList();

            result.LookupFlags = lookupFlags;
            return(result);
        }
Esempio n. 23
0
        private IEnumerable <ushort> GetOptionalFeatureLookupIndices(GlyphTypeface typeface, Tag script, Tag langSys, Tag feature)
        {
            dynamic fontTable       = this.GetFontTable(typeface);
            dynamic fontTableHeader = this.GetFontTableHeader();
            dynamic featureList     = new AccessPrivateWrapper(fontTableHeader.GetFeatureList(fontTable.Wrapped));

            dynamic langSysTable = this.GetLangSysTable(script, langSys, fontTable);
            dynamic featureTable = new AccessPrivateWrapper(langSysTable.FindFeature(fontTable.Wrapped, featureList.Wrapped, TagConverter.UintFromTag(feature)));

            if (featureTable.IsNull)
            {
                throw new ArgumentOutOfRangeException("feature");
            }

            return(this.GetLookupIndicesFromFeatureTable(typeface, featureTable));
        }
Esempio n. 24
0
        private ContextTransformationRule ParseContextTransformationRule(dynamic fontTable, dynamic rule, Func <dynamic, int, ushort> idProjection)
        {
            dynamic contextualLookupsTable = new AccessPrivateWrapper(rule.ContextualLookups(fontTable.Wrapped));

            return(new ContextTransformationRule
            {
                Context = this.GetEnumerableFromInternalList(
                    () => rule.GlyphCount(fontTable.Wrapped),
                    i => (ushort)idProjection(rule, i)).ToList(),
                TransformationSets = this.GetEnumerableFromInternalList(
                    () => rule.SubstCount(fontTable.Wrapped),
                    i => new ContextTransformationSet
                {
                    FirstGlyphIndex = contextualLookupsTable.SequenceIndex(fontTable.Wrapped, i),
                    Transformations = this.GetTransformationTablesByLookupIndex(fontTable, contextualLookupsTable.LookupIndex(fontTable.Wrapped, i))
                }).ToList()
            });
        }
Esempio n. 25
0
        private IEnumerable <ushort> GetRequiredFeatureLookupIndices(GlyphTypeface typeface, Tag script, Tag langSys)
        {
            dynamic fontTable    = this.GetFontTable(typeface);
            dynamic langSysTable = this.GetLangSysTable(script, langSys, fontTable);

            dynamic fontTableHeader = this.GetFontTableHeader();
            dynamic featureList     = fontTableHeader.GetFeatureList(fontTable.Wrapped);

            dynamic requiredFeatureTable = new AccessPrivateWrapper(langSysTable.RequiredFeature(fontTable.Wrapped, featureList));

            // The lang sys may not have a required feature
            if (requiredFeatureTable.IsNull)
            {
                return(Enumerable.Empty <ushort>());
            }

            return(this.GetLookupIndicesFromFeatureTable(typeface, requiredFeatureTable));
        }
Esempio n. 26
0
        /// <summary>
        /// Gets a collection of all scripts supported by the typeface. List of all known script tags can be found here: http://www.microsoft.com/typography/developers/opentype/scripttags.aspx .
        /// </summary>
        /// <param name="typeface">The typeface.</param>
        /// <returns>Collection of tags.</returns>
        public IEnumerable <Tag> GetScriptTags(GlyphTypeface typeface)
        {
            dynamic fontTableHeader = this.GetFontTableHeader();
            dynamic fontTable       = this.GetFontTable(typeface);

            if (!fontTable.IsPresent)
            {
                return(Enumerable.Empty <Tag>());
            }

            dynamic scriptList = new AccessPrivateWrapper(fontTableHeader.GetScriptList(fontTable.Wrapped));

            var uintTags = this.GetEnumerableFromInternalList(
                () => scriptList.GetScriptCount(fontTable.Wrapped),
                p => (uint)scriptList.GetScriptTag(fontTable.Wrapped, p));

            return(uintTags.Select(TagConverter.TagFromUint));
        }
Esempio n. 27
0
        /// <summary>
        /// Gets the character to glyph ID mapping.
        /// </summary>
        /// <param name="typeface">The typeface.</param>
        /// <returns>Dictionary with pairs character - glyphId.</returns>
        public IDictionary <char, ushort> GetCharacterToGlyphIdMapping(GlyphTypeface typeface)
        {
            /* Generate sequence of all characters representable in .Net and feed it into WPF conversion function
             * - it will process the characters through its internal representation of CMAP and return glyph IDs. */
            var conversionChars = Enumerable.Range(0, ushort.MaxValue).Select(p => (char)p).ToArray();
            var characterBuffer = new CharacterBufferRange(conversionChars, 0, conversionChars.Length);

            dynamic typefaceDynamic = new AccessPrivateWrapper(typeface);

            var glyphIdArray = new ushort[conversionChars.Length];

            typefaceDynamic.GetGlyphIndicesOptimized(characterBuffer, glyphIdArray);

            return(conversionChars
                   .Zip(glyphIdArray, (charId, glyphId) => new { charId, glyphId })
                   .Where(p => p.glyphId != 0)
                   .ToDictionary(p => p.charId, p => p.glyphId));
        }
Esempio n. 28
0
        public async void FindInSourceControlExplorerAsync(string localPath)
        {
            bool isConnected = SourceControlExplorer.Connected;

            logger.Log(string.Format("SCE is connected: {0}", isConnected), LogLevel.Verbose);
            if (!isConnected)
            {
                SourceControlExplorer.Navigate(@"$/");
                isConnected = await Task <bool> .Factory.StartNew(() => Utilities.Poll(() => SourceControlExplorer.Connected, 60, 250));

                logger.Log(string.Format("SCE is connected: {0}", isConnected), LogLevel.Verbose);
            }

            string serverPath       = GetServerPathFromLocal(localPath);
            string serverPathFolder = serverPath.Substring(0, serverPath.LastIndexOf("/"));
            string currentFolder    = SourceControlExplorer.CurrentFolderItem.SourceServerPath;

            logger.Log(string.Format("serverPathFolder is {0} :  currentFolder is: {1}", serverPathFolder, SourceControlExplorer.CurrentFolderItem.SourceServerPath), LogLevel.Verbose);
            if (serverPathFolder.Equals(currentFolder, StringComparison.CurrentCultureIgnoreCase))
            {
                logger.Log("Navigate to root", LogLevel.Verbose);
                SourceControlExplorer.Navigate(@"$/");
            }

            SourceControlExplorer.Navigate(serverPath);

            PropertyInfo propInfoExplorerToolWindow = typeof(VersionControlExplorerExt).GetProperty("ExplorerToolWindow", BindingFlags.NonPublic | BindingFlags.Instance);
            object       explorerToolWindow         = propInfoExplorerToolWindow.GetValue(SourceControlExplorer);
            dynamic      sccToolWindow    = new AccessPrivateWrapper(explorerToolWindow);
            dynamic      explorer         = new AccessPrivateWrapper(sccToolWindow.SccExplorer);
            dynamic      listViewExplorer = explorer.listViewExplorer;

            if (listViewExplorer != null)
            {
                logger.Log("Try to ensure item is selected in list view", LogLevel.Verbose);
                Func <bool> condition = () => listViewExplorer.SelectedIndices.Count > 0;
                Action      action    = () =>
                {
                    int selectedIndex = listViewExplorer.SelectedIndices[0];
                    listViewExplorer.EnsureVisible(selectedIndex);
                };
                Utilities.DispatcherPoll(condition, action, 60, 250);
            }
        }
Esempio n. 29
0
        protected IGlyphTransformationTable ParseChainingSubstitutionTable(int subTableOffset, dynamic fontTable, LookupFlags lookupFlags)
        {
            var     type   = typeof(GlyphTypeface).Assembly.GetType("MS.Internal.Shaping.ChainingSubtable");
            dynamic table  = new AccessPrivateWrapper(type.Instantiate(subTableOffset));
            ushort  format = table.Format(fontTable.Wrapped);

            switch (format)
            {
            case 1:
                return(this.ParseGlyphChainingSubstitutionTable(subTableOffset, fontTable, lookupFlags));

            case 2:
                return(this.ParseClassChainingSubstitutionTable(subTableOffset, fontTable, lookupFlags));

            case 3:
                return(this.ParseCoverageChainingSubstitutionTable(subTableOffset, fontTable, lookupFlags));

            default:
                throw new UnknownTableFormatException(type, format);
            }
        }
Esempio n. 30
0
        public Dictionary <ushort, ushort> GetMarkAttachClassIds(GlyphTypeface typeface)
        {
            dynamic header    = this.GetFontTableHeader();
            dynamic fontTable = this.GetFontTable(typeface);

            if (!fontTable.IsPresent)
            {
                return(new Dictionary <ushort, ushort>());
            }

            dynamic classDef = new AccessPrivateWrapper(header.GetMarkAttachClassDef(fontTable.Wrapped));

            if (classDef.IsInvalid)
            {
                return(new Dictionary <ushort, ushort>());
            }

            return(Enumerable.Range(0, ushort.MaxValue)
                   .ToDictionary(
                       glyphId => (ushort)glyphId,
                       glyphId => (ushort)classDef.GetClass(fontTable.Wrapped, (ushort)glyphId)));
        }
	protected void DownloadFromFolderDiffManager(string outputDir) {

		var hatpack = new HatPackage();
		dynamic man = new AccessPrivateWrapper(hatpack._wrapped.FolderDiffManager);
		if (man != null) {
			dynamic toolWindow = new AccessPrivateWrapper(man.FolderDiffToolWindows[0]);
			if (toolWindow != null) {
				dynamic diffControl = new AccessPrivateWrapper(toolWindow.FolderDiffControl);
				if (diffControl != null) {
					var diff = diffControl.FolderDiff;
					if (diff != null) {
						var coll = hatpack.HatterasService.TeamProjectCollection as TfsTeamProjectCollection;

						var getter = new FolderDiffInternalsGetter(diff, coll, outputDir);
						getter.TraceWriter = WriteProgressMessage;
						getter.Go();

					}
				}
			}
		}
	}
Esempio n. 32
0
        public override bool Execute() {
            int buildId;

            try {
                dynamic buildEngine = BuildEngine.AccessPrivate();

                var host = buildEngine.host;
                dynamic pHost = new AccessPrivateWrapper(host);
                var bp = pHost.buildParameters;
                dynamic pBp = new AccessPrivateWrapper(bp);

                buildId = pBp.buildId;

                lock (typeof(InvokeBuild)) {
                    if (buildId <= MaxBuildId) {
                        // this happens when we build a solution, and it wants to build each project
                        return true;
                    }
                    MaxBuildId = buildId;
                }
            }
            catch {
            
            }

            using (new PushDirectory(Environment.CurrentDirectory)) {
                try {
                    if (Location.Is()) {
                        Environment.CurrentDirectory = Location.GetFullPath();
                    }

                    if (string.IsNullOrWhiteSpace(ScriptFile)) {
                        // search for it.
                        ScriptFile = new[] {
                            @"copkg\.buildinfo", @"contrib\.buildinfo", @"contrib\coapp\.buildinfo", @".buildinfo"
                        }.WalkUpPaths();

                        if (string.IsNullOrEmpty(ScriptFile)) {
                            throw new ClrPlusException(@"Unable to find .buildinfo file anywhere in the current directory structure.");
                        }
                    }

                    if (!File.Exists(ScriptFile)) {
                        throw new ClrPlusException(@"Unable to find Invoke-build script file '{0}'.".format(ScriptFile));
                    }

                    string[] defines = Defines.IsNullOrEmpty() ? new string[0] : Defines.Select(each => each.ItemSpec).ToArray();

                    using (var buildScript = new BuildScript(ScriptFile)) {

                        buildScript.BuildMessage += message => {
                            try {
                                switch (message.EventType) {
                                    case "BuildWarning":
                                        Log.LogWarning(message.Subcategory, message.Code, message.HelpKeyword, message.File, message.LineNumber, message.ColumnNumber, message.EndLineNumber, message.EndColumnNumber, message.Message);
                                        break;
                                    case "BuildError":
                                        Log.LogError(message.Subcategory, message.Code, message.HelpKeyword, message.File, message.LineNumber, message.ColumnNumber, message.EndLineNumber, message.EndColumnNumber, message.Message);
                                        break;
                                    case "ProjectStarted":
                                        Log.LogExternalProjectStarted(message.Message, message.HelpKeyword, message.ProjectFile, message.TargetNames);
                                        break;
                                    case "ProjectFinished":
                                        Log.LogExternalProjectFinished(message.Message, message.HelpKeyword, message.ProjectFile, message.Succeeded);
                                        break;
                                    case "TaskStarted":
                                        Log.LogMessage(MessageImportance.Low, message.Message);
                                        break;
                                    case "TaskFinished":
                                        Log.LogMessage(MessageImportance.Low, message.Message);
                                        break;
                                    case "TargetStarted":
                                        Log.LogMessage(MessageImportance.Low, message.Message);
                                        break;
                                    case "TargetFinished":
                                        Log.LogMessage(MessageImportance.Low, message.Message);
                                        break;
                                    case "BuildStarted":
                                        Log.LogMessage(MessageImportance.Low, message.Message);
                                        break;
                                    case "BuildFinished":
                                        Log.LogMessage(MessageImportance.Low, message.Message);
                                        break;
                                    case "BuildMessage":
                                        Log.LogMessage((MessageImportance)message.Importance, message.Message);
                                        break;
                                    default:
                                        Log.LogMessage(MessageImportance.Low, message.Message);
                                        break;
                                }
                                
                            }
                            catch (Exception e) {
                                LogError("{0}/{1}/{2}", e.GetType().Name, e.Message, e.StackTrace );
                            }
                            return false;
                        };

                        foreach (var i in defines) {
                            var p = i.IndexOf("=");
                            var k = p > -1 ? i.Substring(0, p) : i;
                            var v = p > -1 ? i.Substring(p + 1) : "";
                            buildScript.AddMacro(k, v);
                        }

                        var targets = Targets.IsNullOrEmpty() ? new string[0] : Targets.Select(each => each.ItemSpec).ToArray();

                        if (Targets.IsNullOrEmpty()) {
                            targets = new string[] {
                                "default"
                            };
                        }

                        Environment.SetEnvironmentVariable("MaxThreads", "" + MaxThreads);
                        Environment.SetEnvironmentVariable("HIDE_THREADS", "true");

                        buildScript.MaxThreads = MaxThreads;
                        return buildScript.Execute(targets);
                    }

                } catch (Exception e) {
                    LogError("{0}/{1}/{2}".format(e.GetType().Name, e.Message, e.StackTrace));
                    return false;
                } finally {
                    Environment.SetEnvironmentVariable("HIDE_THREADS", null);
                    Environment.SetEnvironmentVariable("MaxThreads", null);
                }
            }

        }
        public void PrivateTest()
        {
            var codeWriter = new CodeWriter();
            dynamic codeWriterAccessor = new AccessPrivateWrapper( codeWriter );

            Assert.IsNull( codeWriterAccessor.lastLine, "After initialize CodeWriter lastLine must be null" );
            Assert.IsNotNull( codeWriterAccessor.Lines, "Lines must be not null" );
            Assert.AreEqual( 0, codeWriterAccessor.Lines.Count, "Lines must be empty" );

            codeWriter.Append( "Test" );
            Assert.That( codeWriterAccessor.lastLine, Is.Not.Null, "After Append text lastLine must be not null" );
            Assert.That( codeWriter.Lines, Is.Not.Null.And.Count.EqualTo( 1 ),
                         "After first Append text code write must consist from one line" );

            codeWriter.AppendLine( "Text" );
            Assert.That( (object)codeWriterAccessor.lastLine, Is.Null, "After initialize CodeWriter lastLine must be null" );
            Assert.That( codeWriter.Lines, Is.Not.Null.And.Count.EqualTo( 1 ),
                         "After first Append text code write must consist from one line" );

            codeWriterAccessor.InnerAppend( "Text", false );
            Assert.That( codeWriterAccessor.lastLine, Is.Not.Null, "After Append text lastLine must be not null" );
            Assert.That( codeWriter.Lines, Is.Not.Null.And.Count.EqualTo( 2 ), "CodeWrite must consist from two line" );

            codeWriterAccessor.InnerAppend( "Text", true );
            Assert.That( (object)codeWriterAccessor.lastLine, Is.Null, "After Append text lastLine must be null" );
            Assert.That( codeWriter.Lines, Is.Not.Null.And.Count.EqualTo( 2 ), "CodeWrite must consist from two line" );

            codeWriter.AppendText( "new\r\nline" );
            Assert.That( codeWriterAccessor.lastLine, Is.Not.Null, "Appended text not finish last line, but CodeWriter finish it" );
            Assert.That( codeWriter.Lines, Is.Not.Null.And.Count.EqualTo( 4 ), "CodeWrite must consist from four line" );

            codeWriter.AppendText( "new\r\nlines\r\n" );
            Assert.That( (object)codeWriterAccessor.lastLine, Is.Null, "Appended text finish last line, but CodeWriter doesn't" );
            Assert.That( codeWriter.Lines, Is.Not.Null.And.Count.EqualTo( 5 ), "CodeWrite must consist from five line" );
        }
Esempio n. 34
0
        public void OnceUnitOpened_TransactionPropertyIsNotPopulatedUntilEnsureBegunCalled()
        {
            //Arrange
            var setup = new NhibernateTestSetupHelper();

            using (var writer = setup.ProviderSetup.UnitFactory.Create())
            {
                dynamic access = new AccessPrivateWrapper(writer.EntityRepository.Transaction);
                Assert.Null(access._nhTransaction);
                writer.EntityRepository.Transaction.EnsureBegun();
                Assert.NotNull(access._nhTransaction);
            }
        }
Esempio n. 35
0
        public void UnitTestCtor_SessionSurvivesUnits()
        {
            // Arrange
            var setup = new NhibernateTestSetupHelper();
            Guid entitySessionId;
            Guid revisionSessionId;
            Guid schemaSessionId;
            
            // Act
            using (var writer = setup.ProviderSetup.UnitFactory.Create())
            {
                dynamic entitySession = new AccessPrivateWrapper(((EntityRepository)writer.EntityRepository).Helper.NhSession);
                dynamic schemaSession = new AccessPrivateWrapper(((SchemaRepository)writer.EntityRepository.Schemas).Helper.NhSession);
                dynamic revisionSession = new AccessPrivateWrapper(((RevisionRepository)writer.EntityRepository.Revisions).Helper.NhSession);
                entitySessionId = entitySession.SessionId;
                schemaSessionId = schemaSession.SessionId;
                revisionSessionId = revisionSession.SessionId;
            }

            // Assert
            using (var writer = setup.ProviderSetup.UnitFactory.Create())
            {
                dynamic entitySession = new AccessPrivateWrapper(((EntityRepository) writer.EntityRepository).Helper.NhSession);
                dynamic schemaSession = new AccessPrivateWrapper(((SchemaRepository)writer.EntityRepository.Schemas).Helper.NhSession);
                dynamic revisionSession = new AccessPrivateWrapper(((RevisionRepository)writer.EntityRepository.Revisions).Helper.NhSession);

                Assert.AreNotEqual(entitySession.SessionId, Guid.Empty);
                Assert.AreNotEqual(schemaSession.SessionId, Guid.Empty);
                Assert.AreNotEqual(revisionSession.SessionId, Guid.Empty);
                Assert.AreEqual(entitySessionId, entitySession.SessionId);
                Assert.AreEqual(schemaSessionId, entitySession.SessionId);
                Assert.AreEqual(revisionSessionId, entitySession.SessionId);
                Assert.AreEqual(entitySession.SessionId, schemaSession.SessionId);
                Assert.AreEqual(entitySession.SessionId, revisionSession.SessionId);
            }
        }