コード例 #1
1
 public void AddMissingExceptions()
 {
     using (var stream = typeof(ExtractorTest).GetEmbedded("testArchive.zip"))
     using (var microServer = new MicroServer("archive.zip", stream))
     {
         var implementation = new Implementation {ManifestDigest = new ManifestDigest(sha1New: "invalid"), RetrievalMethods = {new Archive {Href = microServer.FileUri}}};
         Assert.Throws<DigestMismatchException>(() => implementation.AddMissing(new SilentTaskHandler()));
     }
 }
コード例 #2
1
        public void AddMissingArchive()
        {
            using (var stream = typeof(ExtractorTest).GetEmbedded("testArchive.zip"))
            using (var microServer = new MicroServer("archive.zip", stream))
            {
                var implementation = new Implementation {RetrievalMethods = {new Archive {Href = microServer.FileUri}}};
                implementation.AddMissing(new SilentTaskHandler());
                Assert.AreEqual(ArchiveSha256Digest, implementation.ManifestDigest.Sha256New);

                var archive = (Archive)implementation.RetrievalMethods[0];
                Assert.AreEqual(Archive.MimeTypeZip, archive.MimeType);
                Assert.AreEqual(stream.Length, archive.Size);
            }
        }
コード例 #3
0
ファイル: FieldExtensionTest.cs プロジェクト: stormleoxia/lx
 public void SetFieldWithClassTest()
 {
     var container = new DummyContainer();
     var newInstance = new Implementation();
     container.SetField("_instance", newInstance);
     Assert.AreEqual(newInstance, container.Instance);
 }
コード例 #4
0
        /// <summary>
        /// generate a mock object that looks like EventLog, and return it
        /// </summary>
        /// <returns>a mock of Eventlog</returns>
        public static Implementation<EventLog> GetEventLogMock()
        {
            Implementation<EventLog> mock = new Implementation<EventLog>();

               mock.Register("get_Source")
                  .Execute(() =>
                  {
                      // we don't care about the Source property for testing purposes
                      return String.Empty;
                  });

            mock.Register("set_Source")
                    .Execute((string theValue) =>
                    {
                        // we don't care about the Source property for testing purposes
                    });

            mock.Register(instance => instance.WriteEvent(Argument<EventInstance>.Any, Argument<object[]>.Any))
                .Execute((EventInstance eventInstance, object[] args) =>
                {
                    mockLogEntries.Add(
                            new Tuple<int, EventLogEntryType, long, string>
                            (
                                eventInstance.CategoryId,
                                eventInstance.EntryType,
                                eventInstance.InstanceId,
                                args.Aggregate((a, b) => string.Format("{0}\r\n\r\n{1}", a, b)).ToString()
                            )
                        );
                });

            return mock;
        }
コード例 #5
0
 public ChangeInterfaceOfClassifierCommand(
     Implementation existingInterface, 
     ClassifierDictionary classifiers,
     MessageSystem messageSystem)
 {
     _existingInterface = existingInterface;
     _classifiers = classifiers;
     _messageSystem = messageSystem;
 }
コード例 #6
0
ファイル: Absy.cs プロジェクト: Chenguang-Zhu/ICE-C5
 public CallSite(Implementation impl, Block b, int stmt, ProcedureSummaryEntry summaryEntry) {
   Contract.Requires(summaryEntry != null);
   Contract.Requires(b != null);
   Contract.Requires(impl != null);
   this.Impl = impl;
   this.Block = b;
   this.Statement = stmt;
   this.SummaryEntry = summaryEntry;
 }
コード例 #7
0
 private Implementation GetFor(object obj)
 {
     lock (_cache)
     {
         var type = obj.GetType();
         Implementation rv;
         if (!_cache.TryGetValue(type, out rv))
             _cache[type] = rv = new Implementation(type);
         return rv;
     }
 }
コード例 #8
0
        /// <summary>
        /// Creates a new owned implementation node.
        /// </summary>
        /// <param name="digest">The digest identifying the implementation.</param>
        /// <param name="implementation">Information about the implementation from a <see cref="Feed"/> file.</param>
        /// <param name="parent">The node of the feed owning the implementation.</param>
        /// <param name="store">The <see cref="IStore"/> the implementation is located in.</param>
        /// <exception cref="FormatException">The manifest file is not valid.</exception>
        /// <exception cref="IOException">The manifest file could not be read.</exception>
        /// <exception cref="UnauthorizedAccessException">Read access to the file is not permitted.</exception>
        public OwnedImplementationNode(ManifestDigest digest, [NotNull] Implementation implementation, [NotNull] FeedNode parent, [NotNull] IStore store)
            : base(digest, store)
        {
            #region Sanity checks
            if (implementation == null) throw new ArgumentNullException("implementation");
            if (parent == null) throw new ArgumentNullException("parent");
            if (store == null) throw new ArgumentNullException("store");
            #endregion

            _parent = parent;
            _implementation = implementation;
        }
コード例 #9
0
ファイル: Player.cs プロジェクト: Aceltis/ProjetPoo
        public Player(IMap map, String name, String Civ, Implementation.PlayerColor col)
        {
            if (Civ == "INFO")
                Civilization = CivilizationType.INFO;
            else
                Civilization = CivilizationType.EII;

            Teachers = new List<ITeacher>();
            Students = new List<IStudent>();

            Name = name;
            Cities = new List<ICity>();
            Status = StatusType.InGame;
            Color = col;
        }
コード例 #10
0
ファイル: RunHook.cs プロジェクト: 0install/0install-win
        /// <summary>
        /// Hooks into the creation of new processes on the current thread to inject API hooks.
        /// </summary>
        /// <param name="selections">The implementations chosen for launch.</param>
        /// <param name="executor">The executor used to launch the new process.</param>
        /// <param name="feedManager">Provides access to remote and local <see cref="Feed"/>s. Handles downloading, signature verification and caching.</param>
        /// <param name="handler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</param>
        /// <exception cref="ImplementationNotFoundException">The main implementation is not cached (possibly because it is installed natively).</exception>
        public RunHook(Selections selections, IExecutor executor, IFeedManager feedManager, ITaskHandler handler)
        {
            var feed = feedManager[selections.InterfaceUri];
            _target = new FeedTarget(selections.InterfaceUri, feed);

            var mainImplementation = selections.MainImplementation;
            _implementationDir = executor.GetImplementationPath(mainImplementation);
            _mainImplementation = feed[mainImplementation.ID];

            _handler = handler;
            _registryFilter = GetRegistryFilter();
            _relaunchControl = GetRelaunchControl();

            Log.Info("Activating API hooking");
            _hookW = LocalHook.Create(LocalHook.GetProcAddress("kernel32.dll", "CreateProcessW"), new UnsafeNativeMethods.DCreateProcessW(CreateProcessWCallback), null);
            _hookW.ThreadACL.SetInclusiveACL(new[] {Thread.CurrentThread.ManagedThreadId});
            _hookA = LocalHook.Create(LocalHook.GetProcAddress("kernel32.dll", "CreateProcessA"), new UnsafeNativeMethods.DCreateProcessA(CreateProcessACallback), null);
            _hookA.ThreadACL.SetInclusiveACL(new[] {Thread.CurrentThread.ManagedThreadId});
        }
コード例 #11
0
        public void TestGetImplementation()
        {
            var digest1 = new ManifestDigest(sha256: "123");
            var implementation1 = new Implementation {ManifestDigest = digest1};
            var feed1 = new Feed {Elements = {implementation1}};
            var digest2 = new ManifestDigest(sha256: "abc");
            var implementation2 = new Implementation {ManifestDigest = digest2};
            var feed2 = new Feed {Elements = {implementation2}};
            var feeds = new[] {feed1, feed2};

            Feed feed;
            Assert.AreEqual(implementation1, feeds.GetImplementation(digest1, out feed));
            Assert.AreEqual(feed1, feed);

            Assert.AreEqual(implementation2, feeds.GetImplementation(digest2, out feed));
            Assert.AreEqual(feed2, feed);

            Assert.IsNull(feeds.GetImplementation(new ManifestDigest(sha256: "invalid"), out feed), "No implementation should have been found");
            Assert.IsNull(feed, "No feed should have been found");
        }
コード例 #12
0
        public void TestGetImplementation()
        {
            var digest1 = new ManifestDigest(sha256: "123");
            var implementation1 = new Implementation {ManifestDigest = digest1};
            var feed1 = new Feed {Elements = {implementation1}};
            var digest2 = new ManifestDigest(sha256: "abc");
            var implementation2 = new Implementation {ManifestDigest = digest2};
            var feed2 = new Feed {Elements = {implementation2}};
            var feeds = new[] {feed1, feed2};

            Feed feed;
            feeds.GetImplementation(digest1, out feed).Should().Be(implementation1);
            feed.Should().Be(feed1);

            feeds.GetImplementation(digest2, out feed).Should().Be(implementation2);
            feed.Should().Be(feed2);

            feeds.GetImplementation(new ManifestDigest(sha256: "invalid"), out feed).Should().BeNull(because: "No implementation should have been found");
            feed.Should().BeNull(because: "No feed should have been found");
        }
コード例 #13
0
 public void TestNormalizeRejectLocalPath()
 {
     var implmementation = new Implementation {LocalPath = "subdir"};
     implmementation.Normalize(FeedTest.Test1Uri);
     Assert.IsNull(implmementation.LocalPath);
 }
コード例 #14
0
 public async Task TestDrainFullyAsync()
 {
     Implementation implementation = new Implementation();
     await implementation.TestDrainFullyAsync();
 }
コード例 #15
0
 public async Task TestSplitAsync()
 {
     Implementation implementation = new Implementation();
     await implementation.TestSplitAsync();
 }
コード例 #16
0
ファイル: InstrumentationRegion.cs プロジェクト: ufwt/whoop
 private void ProcessWrapperProcedure(Implementation impl)
 {
     this.InternalImplementation.Proc = impl.Proc;
 }
コード例 #17
0
ファイル: InstrumentationRegion.cs プロジェクト: ufwt/whoop
 private void ProcessRegionBlocks(Implementation impl)
 {
     this.RegionBlocks = impl.Blocks;
     this.RegionHeader = this.CreateRegionHeader();
 }
 public async Task Test429sAsync()
 {
     Implementation implementation = new Implementation(false);
     await implementation.Test429sAsync();
 }
コード例 #19
0
 public void setImplementation(Implementation impl)
 {
     this.impl = impl;
 }
コード例 #20
0
ファイル: Tests.cs プロジェクト: davamix/Katas
 public void Test()
 {
     Assert.Equal(23, Implementation.Solution(10));
 }
コード例 #21
0
ファイル: Tests.cs プロジェクト: davamix/Katas
 public void ValueIsNegative()
 {
     Assert.Equal(0, Implementation.Solution(-15));
 }
コード例 #22
0
ファイル: Tests.cs プロジェクト: davamix/Katas
 public void ValueIsZero()
 {
     Assert.Equal(0, Implementation.Solution(0));
 }
コード例 #23
0
ファイル: Tests.cs プロジェクト: davamix/Katas
 public void Test200()
 {
     Assert.Equal(9168, Implementation.Solution(200));
 }
コード例 #24
0
 public FollowSocialPersonaIntent()
 {
     Self = Implementation.Constructor();
 }
コード例 #25
0
 public PollCapabilityInput()
 {
     Self = Implementation.Constructor();
 }
コード例 #26
0
        public void AddMissingRecipe()
        {
            using (var stream = typeof(ArchiveExtractorTest).GetEmbeddedStream("testArchive.zip"))
            using (var microServer = new MicroServer("archive.zip", stream))
            {
                var implementation = new Implementation {RetrievalMethods = {new Recipe {Steps = {new Archive {Href = microServer.FileUri}}}}};
                implementation.AddMissing(new SilentTaskHandler());
                implementation.ManifestDigest.Sha256New.Should().Be(ArchiveSha256Digest);

                var archive = (Archive)((Recipe)implementation.RetrievalMethods[0]).Steps[0];
                archive.MimeType.Should().Be(Archive.MimeTypeZip);
                archive.Size.Should().Be(stream.Length);
            }
        }
コード例 #27
0
        public PetrolPumpWindow()
        {
            this.assemblyName = this.GetType().Assembly.FullName;

            this.InitializeComponent();

            Func<Image>[] largeSegments = new Func<Image>[8];
            Func<Image>[] smallSegments = new Func<Image>[8];
            for (int i = 0; i < 8; i++)
            {
                int n = i;

                largeSegments[i] = () =>
                {
                    Image image = new Image();
                    BitmapImage source = new BitmapImage();
                    source.BeginInit();
                    source.UriSource = new Uri("pack://application:,,,/" + this.assemblyName + ";component/images/large" + n + ".png");
                    source.EndInit();
                    image.Source = source;
                    image.Width = source.PixelWidth;
                    image.Height = source.PixelHeight;
                    return image;
                };

                smallSegments[i] = () =>
                {
                    Image image = new Image();
                    BitmapImage source = new BitmapImage();
                    source.BeginInit();
                    source.UriSource = new Uri("pack://application:,,,/" + this.assemblyName + ";component/images/small" + n + ".png");
                    source.EndInit();
                    image.Source = source;
                    image.Width = source.PixelWidth;
                    image.Height = source.PixelHeight;
                    return image;
                };
            }

            IReadOnlyList<IReadOnlyList<int>> layouts = new[]
            {
                new[] { 0, 1, 2, 4, 5, 6 },
                new[] { 2, 5 },
                new[] { 0, 1, 3, 5, 6 },
                new[] { 0, 2, 3, 5, 6 },
                new[] { 2, 3, 4, 5 },
                new[] { 0, 2, 3, 4, 6 },
                new[] { 0, 1, 2, 3, 4, 6 },
                new[] { 2, 5, 6 },
                new[] { 0, 1, 2, 3, 4, 5, 6 },
                new[] { 2, 3, 4, 5, 6 }
            };
            Func<Grid>[] largeNumberImages = new Func<Grid>[10];
            Func<Grid>[] smallNumberImages = new Func<Grid>[10];
            for (int i = 0; i < 10; i++)
            {
                IReadOnlyList<int> layout = layouts[i];

                largeNumberImages[i] = () =>
                {
                    Grid grid = new Grid();
                    foreach (int n in layout)
                    {
                        grid.Children.Add(largeSegments[n]());
                    }
                    return grid;
                };

                smallNumberImages[i] = () =>
                {
                    Grid grid = new Grid();
                    foreach (int n in layout)
                    {
                        grid.Children.Add(smallSegments[n]());
                    }
                    return grid;
                };
            }

            Func<Grid> largeDotImage = () =>
            {
                Grid grid = new Grid();
                grid.Children.Add(largeSegments[7]());
                return grid;
            };

            Func<Grid> smallDotImage = () =>
            {
                Grid grid = new Grid();
                grid.Children.Add(smallSegments[7]());
                return grid;
            };

            Func<Grid> largeDashImage = () =>
            {
                Grid grid = new Grid();
                grid.Children.Add(largeSegments[3]());
                return grid;
            };

            Func<Grid> smallDashImage = () =>
            {
                Grid grid = new Grid();
                grid.Children.Add(smallSegments[3]());
                return grid;
            };

            this.largeNumberImage0 = largeNumberImages[0];
            this.smallNumberImage0 = smallNumberImages[0];
            this.largeNumberImage1 = largeNumberImages[1];
            this.smallNumberImage1 = smallNumberImages[1];
            this.largeNumberImage2 = largeNumberImages[2];
            this.smallNumberImage2 = smallNumberImages[2];
            this.largeNumberImage3 = largeNumberImages[3];
            this.smallNumberImage3 = smallNumberImages[3];
            this.largeNumberImage4 = largeNumberImages[4];
            this.smallNumberImage4 = smallNumberImages[4];
            this.largeNumberImage5 = largeNumberImages[5];
            this.smallNumberImage5 = smallNumberImages[5];
            this.largeNumberImage6 = largeNumberImages[6];
            this.smallNumberImage6 = smallNumberImages[6];
            this.largeNumberImage7 = largeNumberImages[7];
            this.smallNumberImage7 = smallNumberImages[7];
            this.largeNumberImage8 = largeNumberImages[8];
            this.smallNumberImage8 = smallNumberImages[8];
            this.largeNumberImage9 = largeNumberImages[9];
            this.smallNumberImage9 = smallNumberImages[9];
            this.largeDotImage = largeDotImage;
            this.smallDotImage = smallDotImage;
            this.largeDashImage = largeDashImage;
            this.smallDashImage = smallDashImage;

            Transaction.RunVoid(() => { this.implementation = new Implementation(this); });
        }
コード例 #28
0
 public List <Cmd> CreateInitCmds(Implementation impl)
 {
     return(new List <Cmd>());
 }
コード例 #29
0
 public override void Implement(MethodBodyTransformationContext context)
 {
     Implementation implementation = new Implementation(this, context);
     implementation.Implement();
 }
コード例 #30
0
 /// <inheritdoc />
 public void Convert(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, int byteCount, bool flush, out int charsUsed, out int bytesUsed, out bool completed)
 {
     Implementation.Convert(chars, charIndex, charCount, bytes, byteIndex, byteCount, flush, out charsUsed, out bytesUsed, out completed);
 }
コード例 #31
0
ファイル: SocialPostIntents.cs プロジェクト: yallie/ApexSharp
 public SocialPostIntents()
 {
     Self = Implementation.Constructor();
 }
コード例 #32
0
        public void TestNormalizeLocalPath()
        {
            var localUri = new FeedUri(WindowsUtils.IsWindows ? @"C:\local\feed.xml" : "/local/feed.xml");

            var implementation1 = new Implementation {ID = "./subdir"};
            implementation1.Normalize(localUri);
            implementation1.ID
                .Should().Be(WindowsUtils.IsWindows ? @"C:\local\.\subdir" : "/local/./subdir");
            implementation1.LocalPath
                .Should().Be(WindowsUtils.IsWindows ? @"C:\local\.\subdir" : "/local/./subdir");

            var implementation2 = new Implementation {ID = "./wrong", LocalPath = "subdir"};
            implementation2.Normalize(localUri);
            implementation2.ID.Should().Be("./wrong");
            implementation2.LocalPath
                .Should().Be(WindowsUtils.IsWindows ? @"C:\local\subdir" : "/local/subdir");
        }
コード例 #33
0
ファイル: InstrumentationRegion.cs プロジェクト: ufwt/whoop
 private void ProcessWrapperImplementation(Implementation impl)
 {
     this.InternalImplementation = impl;
 }
コード例 #34
0
 public async Task TestEmptyPages()
 {
     Implementation implementation = new Implementation();
     await implementation.TestEmptyPages();
 }
コード例 #35
0
        public void TestNormalizeRejectRelativeHref()
        {
            var relative = new Archive {Href = new Uri("relative", UriKind.Relative)};
            var absolute = new Archive {Href = new Uri("http://server/absolute.zip", UriKind.Absolute)};
            var implmementation = new Implementation {RetrievalMethods = {relative, absolute}};

            implmementation.Normalize(FeedTest.Test1Uri);
            implmementation.RetrievalMethods.Should().Equal(absolute);
        }
コード例 #36
0
 public async Task TestResumingFromStateAsync()
 {
     Implementation implementation = new Implementation();
     await implementation.TestResumingFromStateAsync();
 }
コード例 #37
0
 static void Main(string[] args)
 {
     Implementation clas = new Implementation();
     clas.StartWork();
 }
コード例 #38
0
        public void TestNormalizeID()
        {
            var implementation = new Implementation {ID = "sha256=123"};
            implementation.Normalize(FeedTest.Test1Uri);
            Assert.AreEqual("123", implementation.ManifestDigest.Sha256);

            implementation = new Implementation {ID = "sha256=wrong", ManifestDigest = new ManifestDigest(sha256: "correct")};
            implementation.Normalize(FeedTest.Test1Uri);
            Assert.AreEqual("correct", implementation.ManifestDigest.Sha256);

            implementation = new Implementation {ID = "abc"};
            implementation.Normalize(FeedTest.Test1Uri);
        }
コード例 #39
0
 /// <inheritdoc />
 public int GetByteCount(char[] chars, int index, int count, bool flush)
 {
     return(Implementation.GetByteCount(chars, index, count, flush));
 }
コード例 #40
0
 public async Task Test429sWithContinuationsAsync()
 {
     Implementation implementation = new Implementation();
     await implementation.Test429sWithContinuationsAsync();
 }
コード例 #41
0
 public void TestNormalizeRejectLocalPath()
 {
     var implmementation = new Implementation {LocalPath = "subdir"};
     implmementation.Normalize(FeedTest.Test1Uri);
     implmementation.LocalPath.Should().BeNull();
 }
コード例 #42
0
 /// <inheritdoc />
 public int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex, bool flush)
 {
     return(Implementation.GetBytes(chars, charIndex, charCount, bytes, byteIndex, flush));
 }
コード例 #43
0
        public void TestNormalizeID()
        {
            var implementation = new Implementation {ID = "sha256=123"};
            implementation.Normalize(FeedTest.Test1Uri);
            implementation.ManifestDigest.Sha256.Should().Be("123");

            implementation = new Implementation {ID = "sha256=wrong", ManifestDigest = new ManifestDigest(sha256: "correct")};
            implementation.Normalize(FeedTest.Test1Uri);
            implementation.ManifestDigest.Sha256.Should().Be("correct");

            implementation = new Implementation {ID = "abc"};
            implementation.Normalize(FeedTest.Test1Uri);
        }
コード例 #44
0
ファイル: DatacloudContacts.cs プロジェクト: yallie/ApexSharp
 public DatacloudContacts()
 {
     Self = Implementation.Constructor();
 }
コード例 #45
0
 public void TestNormalizeCommand()
 {
     var implementation = new Implementation {Main = "main", SelfTest = "test"};
     implementation.Normalize(FeedTest.Test1Uri);
     Assert.AreEqual("main", implementation[Command.NameRun].Path);
     Assert.AreEqual("test", implementation[Command.NameTest].Path);
 }
コード例 #46
0
 public TopicsCapabilityInput()
 {
     Self = Implementation.Constructor();
 }
コード例 #47
0
        public void TestNormalizeLocalPath()
        {
            var localUri = new FeedUri(WindowsUtils.IsWindows ? @"C:\local\feed.xml" : "/local/feed.xml");

            var implementation1 = new Implementation {ID = "./subdir"};
            implementation1.Normalize(localUri);
            Assert.AreEqual(
                expected: WindowsUtils.IsWindows ? @"C:\local\.\subdir" : "/local/./subdir",
                actual: implementation1.ID);
            Assert.AreEqual(
                expected: WindowsUtils.IsWindows ? @"C:\local\.\subdir" : "/local/./subdir",
                actual: implementation1.LocalPath);

            var implementation2 = new Implementation {ID = "./wrong", LocalPath = "subdir"};
            implementation2.Normalize(localUri);
            Assert.AreEqual(
                expected: "./wrong",
                actual: implementation2.ID);
            Assert.AreEqual(
                expected: WindowsUtils.IsWindows ? @"C:\local\subdir" : "/local/subdir",
                actual: implementation2.LocalPath);
        }
コード例 #48
0
ファイル: TypeCheck.cs プロジェクト: ggrov/tacny
 public override Implementation VisitImplementation(Implementation node)
 {
     node.Attributes = RemoveLayerAttribute(node.Attributes);
     return(base.VisitImplementation(node));
 }
コード例 #49
0
        public void TestNormalizeRejectRelativeHref()
        {
            var relative = new Archive {Href = new Uri("relative", UriKind.Relative)};
            var absolute = new Archive {Href = new Uri("http://server/absolute.zip", UriKind.Absolute)};
            var implmementation = new Implementation {RetrievalMethods = {relative, absolute}};

            implmementation.Normalize(FeedTest.Test1Uri);
            CollectionAssert.AreEqual(
                expected: new[] {absolute},
                actual: implmementation.RetrievalMethods);
        }
コード例 #50
0
ファイル: TypeCheck.cs プロジェクト: ggrov/tacny
        public void TypeCheck()
        {
            foreach (var proc in program.Procedures)
            {
                if (!QKeyValue.FindBoolAttribute(proc.Attributes, "yields"))
                {
                    continue;
                }

                int        createdAtLayerNum; // must be initialized by the following code, otherwise it is an error
                int        availableUptoLayerNum = int.MaxValue;
                List <int> attrs = FindLayers(proc.Attributes);
                if (attrs.Count == 1)
                {
                    createdAtLayerNum = attrs[0];
                }
                else if (attrs.Count == 2)
                {
                    createdAtLayerNum     = attrs[0];
                    availableUptoLayerNum = attrs[1];
                }
                else
                {
                    Error(proc, "Incorrect number of layers");
                    continue;
                }
                if (availableUptoLayerNum <= createdAtLayerNum)
                {
                    Error(proc, "Creation layer number must be less than the available upto layer number");
                    continue;
                }
                foreach (Ensures e in proc.Ensures)
                {
                    MoverType moverType = GetMoverType(e);
                    if (moverType == MoverType.Top)
                    {
                        continue;
                    }
                    CodeExpr codeExpr = e.Condition as CodeExpr;
                    if (codeExpr == null)
                    {
                        Error(e, "An atomic action must be a CodeExpr");
                        continue;
                    }
                    if (procToActionInfo.ContainsKey(proc))
                    {
                        Error(proc, "A procedure can have at most one atomic action");
                        continue;
                    }

                    minLayerNum         = int.MaxValue;
                    maxLayerNum         = -1;
                    canAccessSharedVars = true;
                    enclosingProc       = proc;
                    enclosingImpl       = null;
                    base.VisitEnsures(e);
                    canAccessSharedVars = false;
                    if (maxLayerNum > createdAtLayerNum)
                    {
                        Error(e, "A variable being accessed is introduced after this action is created");
                    }
                    else if (availableUptoLayerNum > minLayerNum)
                    {
                        Error(e, "A variable being accessed is hidden before this action becomes unavailable");
                    }
                    else
                    {
                        procToActionInfo[proc] = new AtomicActionInfo(proc, e, moverType, createdAtLayerNum, availableUptoLayerNum);
                    }
                }
                if (errorCount > 0)
                {
                    continue;
                }
                if (!procToActionInfo.ContainsKey(proc))
                {
                    procToActionInfo[proc] = new ActionInfo(proc, createdAtLayerNum, availableUptoLayerNum);
                }
            }
            if (errorCount > 0)
            {
                return;
            }
            foreach (var impl in program.Implementations)
            {
                if (!procToActionInfo.ContainsKey(impl.Proc))
                {
                    continue;
                }
                procToActionInfo[impl.Proc].hasImplementation = true;
            }
            foreach (var proc in procToActionInfo.Keys)
            {
                ActionInfo actionInfo = procToActionInfo[proc];
                if (actionInfo.isExtern && actionInfo.hasImplementation)
                {
                    Error(proc, "Extern procedure cannot have an implementation");
                    continue;
                }
                if (actionInfo.isExtern || actionInfo.hasImplementation)
                {
                    continue;
                }
                if (leastUnimplementedLayerNum == int.MaxValue)
                {
                    leastUnimplementedLayerNum = actionInfo.createdAtLayerNum;
                }
                else if (leastUnimplementedLayerNum != actionInfo.createdAtLayerNum)
                {
                    Error(proc, "All unimplemented atomic actions must be created at the same layer");
                }
            }
            foreach (var g in this.globalVarToSharedVarInfo.Keys)
            {
                var info = globalVarToSharedVarInfo[g];
                if (!this.AllCreatedLayerNums.Contains(info.introLayerNum))
                {
                    Error(g, "Variable must be introduced with creation of some atomic action");
                }
                if (info.hideLayerNum != int.MaxValue && !this.AllCreatedLayerNums.Contains(info.hideLayerNum))
                {
                    Error(g, "Variable must be hidden with creation of some atomic action");
                }
            }
            if (errorCount > 0)
            {
                return;
            }
            this.VisitProgram(program);
            foreach (Procedure proc in program.Procedures)
            {
                if (procToActionInfo.ContainsKey(proc))
                {
                    continue;
                }
                foreach (var ie in proc.Modifies)
                {
                    if (!SharedVariables.Contains(ie.Decl))
                    {
                        continue;
                    }
                    Error(proc, "A ghost procedure must not modify a global variable with layer annotation");
                }
            }
            if (errorCount > 0)
            {
                return;
            }
            YieldTypeChecker.PerformYieldSafeCheck(this);
            new LayerEraser().VisitProgram(program);
        }
コード例 #51
0
        public void GenerateMissingArchive()
        {
            using (var tempDir = new TemporaryDirectory("0install-unit-tests"))
            {
                string feedPath = Path.Combine(tempDir, "feed.xml");
                Directory.CreateDirectory(Path.Combine(tempDir, "impl"));
                FileUtils.Touch(Path.Combine(tempDir, "impl", "file"));

                var archive = new Archive {Href = new Uri("archive.zip", UriKind.Relative)};
                var implementation = new Implementation {LocalPath = "impl", RetrievalMethods = {archive}};

                implementation.AddMissing(new SilentTaskHandler(), new SimpleCommandExecutor {Path = feedPath});

                implementation.LocalPath.Should().BeNull();
                implementation.ManifestDigest.Should().NotBe(default(ManifestDigest));
                archive.Size.Should().NotBe(0);

                File.Exists(Path.Combine(tempDir, "archive.zip")).Should().BeTrue();
            }
        }
コード例 #52
0
        /// <summary>
        /// Sets up the cosmetic data for this model, or, what's displayed in the GUI for the program.<para/>
        /// This specific method populates data that is common across all imported models.
        /// </summary>
        /// <param name="model">The model containing other data, such as the <see cref="Implementation"/>.</param>
        /// <param name="dataTreeParent">This is the instance in the data tree that represents this object in the hierarchy. If null, this method call is skipped.</param>
        /// <param name="dataTreeNameIsImplementation">If <see langword="true"/>, the name of <paramref name="dataTreeParent"/> is the implementation of the model, so the implementation property will not be added.</param>
        public static void SetupCosmeticInformation(ModelConfig model, DataTreeObject dataTreeParent, bool dataTreeNameIsImplementation)
        {
            if (dataTreeParent == null)
            {
                return;
            }
            Implementation impl = model.implementation;

            if (!dataTreeNameIsImplementation)
            {
                // If this is true, the name of the actual node is the implementation, rendering this property useless.

                string implementationName = JavaClassNameStripper.GetWholeClassName(impl.getClass().getName()) ?? "Unknown Implementation";
                dataTreeParent.AddSimpleProperty("Implementation", implementationName.Replace("$", "::"), SilkImage.Config, SilkImage.Config, true);
            }

            // It's imported!
            // ...Unless it's a CompoundConfig. (I mean given the properties below it makes sense, it's just a container, not actual model data.)
            if (impl is Imported imported)
            {
                //RootDataTreeObject.AddSimpleProperty("Scale", model.scale);
                List <object> influences = new List <object>(3);
                if (imported.influences.fog)
                {
                    influences.Add(new DataTreeObjectProperty("Fog", SilkImage.Shading));
                }
                if (imported.influences.lights)
                {
                    influences.Add(new DataTreeObjectProperty("Lights", SilkImage.Light));
                }
                if (imported.influences.projections)
                {
                    influences.Add(new DataTreeObjectProperty("Projections", SilkImage.Texture));
                }
                if (influences.Count > 0)
                {
                    dataTreeParent.AddSimpleProperty("Influenced By...", influences.ToArray(), displaySinglePropertiesInline: false);
                }

                /*
                 * MaterialMapping[] matMaps = imported.materialMappings;
                 * object[] materialProperties = new object[matMaps.Length];
                 * for (int idx = 0; idx < materialProperties.Length; idx++) {
                 *      ConfigReference mtlRef = matMaps[idx].material;
                 *      ConfigReference texCfg = (ConfigReference)mtlRef.getArguments().getOrDefault("Texture", null);
                 *      if (texCfg != null) {
                 *              string texFile = (string)texCfg.getArguments().getOrDefault("File", "?");
                 *              materialProperties[idx] = new DataTreeObjectProperty(texFile, SilkImage.Reference, false);
                 *      } else {
                 *              materialProperties[idx] = matMaps[idx].texture;
                 *      }
                 * }
                 * dataTreeParent.AddSimpleProperty("Textures", materialProperties, SilkImage.Value, SilkImage.Texture, false);
                 */
            }
            List <object> parameters = new List <object>();

            foreach (Parameter prop in model.parameters)
            {
                if (prop is Parameter.Direct direct)
                {
                    DataTreeObject paths = new DataTreeObject {
                        ImageKey = SilkImage.Tag,
                        Text     = "Direct: " + direct.name
                    };
                    int idx = 0;
                    foreach (string path in direct.paths)
                    {
                        paths.AddSimpleProperty("Path " + idx, path);
                        idx++;
                    }
                    parameters.Add(paths);
                }
                else if (prop is Parameter.Choice choice)
                {
                    DataTreeObject choices = new DataTreeObject {
                        ImageKey = SilkImage.Value,
                        Text     = "Choice: " + choice.name + " [Default: " + choice.choice + "]"
                    };
                    List <DataTreeObject> choiceList = new List <DataTreeObject>();
                    foreach (Parameter.Choice.Option option in choice.options)
                    {
                        // choiceList.Add(c);
                        DataTreeObject choiceInfo = new DataTreeObject {
                            ImageKey = SilkImage.Tag,
                            Text     = option.name
                        };
                        ArgumentMap args = option.arguments;
                        object[]    keys = args.keySet().toArray();
                        foreach (object key in keys)
                        {
                            choiceInfo.AddSimpleProperty(key.ToString(), args.get(key));
                        }

                        choiceList.Add(choiceInfo);
                    }
                    choices.AddSimpleProperty("Choices", choiceList.ToArray(), SilkImage.Value, SilkImage.Tag, false);

                    List <DataTreeObject> subDirects = new List <DataTreeObject>();
                    foreach (Parameter.Direct dir in choice.directs)
                    {
                        DataTreeObject dirObj = new DataTreeObject {
                            ImageKey = SilkImage.Tag,
                            Text     = "Direct: " + dir.name
                        };
                        int idx = 0;
                        foreach (string path in dir.paths)
                        {
                            dirObj.AddSimpleProperty("Path " + idx, path);
                            idx++;
                        }
                        subDirects.Add(dirObj);
                    }
                    choices.AddSimpleProperty("Choice Directs", subDirects.ToArray(), SilkImage.Value, SilkImage.Tag, false);
                    parameters.Add(choices);
                }
                else
                {
                    parameters.Add($"{prop.name} [{prop.GetType().FullName}]");
                }
            }
            dataTreeParent.AddSimpleProperty("Parameters", parameters.ToArray(), SilkImage.Value, SilkImage.Tag, false);
        }
コード例 #53
0
 private SelectionCandidate GenerateDummyCandidate(FeedUri feedUri, FeedPreferences feedPreferences, Implementation implementation)
 {
     return new SelectionCandidate(feedUri, feedPreferences, implementation,
         new Requirements(_interfaceUri, Command.NameRun, new Architecture(Architecture.CurrentSystem.OS, Cpu.All)));
 }
コード例 #54
0
 public FeedElementCapabilitiesInput()
 {
     Self = Implementation.Constructor();
 }
コード例 #55
0
 public MyFacade(Bank bank)
 {
     this.bank = bank;
     this.impl = null;
 }
コード例 #56
0
 public ModerationFlagsCollection()
 {
     Self = Implementation.Constructor();
 }
コード例 #57
0
        public void AddMissingSingleFile()
        {
            using (var originalStream = SingleFileData.ToStream())
            using (var microServer = new MicroServer(SingleFileName, originalStream))
            {
                var implementation = new Implementation {RetrievalMethods = {new SingleFile {Href = microServer.FileUri}}};
                implementation.AddMissing(new SilentTaskHandler());
                Assert.AreEqual(_singleFileSha256Digest, "sha256new_" + implementation.ManifestDigest.Sha256New);

                var file = (SingleFile)implementation.RetrievalMethods[0];
                Assert.AreEqual(originalStream.Length, file.Size);
                Assert.AreEqual(SingleFileName, file.Destination);
            }
        }
コード例 #58
0
 public FeedFavorites()
 {
     Self = Implementation.Constructor();
 }
コード例 #59
0
ファイル: AnalysisContext.cs プロジェクト: smackers/lockpwn
 internal Graph <Block> GetImplementationGraph(Implementation impl)
 {
     return(Microsoft.Boogie.Program.GraphFromImpl(impl));
 }
 public async Task TestMergeToSinglePartition()
 {
     Implementation implementation = new Implementation(true);
     await implementation.TestMergeToSinglePartition();
 }