Пример #1
0
        /// <summary>
        /// Returns true of the collection contains a reference of the given
        /// target path
        /// </summary>
        /// <param name="collection">Collection</param>
        /// <param name="targetPath">Target path</param>
        /// <param name="renamed">List of renamed references</param>
        /// <returns></returns>
        private static bool CollectionContains(IEnumerable collection, string targetPath, List <BaseReference> renamed)
        {
            string strippedPath = null;

            if (targetPath.ToLower().EndsWith(".deploy") && renamed != null)
            {
                strippedPath = targetPath.Substring(0, targetPath.Length - 7).ToLower();
            }

            foreach (object obj in collection)
            {
                BaseReference reference = obj as BaseReference;
                if (reference == null || reference.TargetPath == null)
                {
                    continue;
                }

                if (strippedPath != null && reference.TargetPath.ToLower() == strippedPath)
                {
                    renamed.Add(reference);
                }


                if (reference.TargetPath.ToLower() == targetPath.ToLower())
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
    public BaseReference CreateCopy()
    {
        BaseReference <TBase, TVariable> copy = (BaseReference <TBase, TVariable>)System.Activator.CreateInstance(GetType());

        copy._useConstant   = _useConstant;
        copy._constantValue = _constantValue;
        copy._variable      = _variable;

        return(copy);
    }
Пример #3
0
        internal override BaseReference TransferTo(BaseReference reference)
        {
            IStorable     storable      = reference.InternalValue();
            BaseReference baseReference = AllocateAndPin(storable, ItemSizes.SizeOf(storable));

            (storable as ITransferable)?.TransferTo(this);
            baseReference.UnPinValue();
            reference.ScalabilityCache.Free(reference);
            return(baseReference);
        }
 private static int AddBaseReference(ref ArrayList list, BaseReference baseRef)
 {
     if ((baseRef != null) && !string.IsNullOrEmpty(baseRef.SourcePath))
     {
         if (list == null)
         {
             list = new ArrayList();
         }
         return(list.Add(baseRef));
     }
     return(-1);
 }
        public override BaseReference TransferTo(BaseReference reference)
        {
            IStorable     storable      = reference.InternalValue();
            BaseReference baseReference = base.AllocateAndPin(storable, ItemSizes.SizeOf(storable));
            ITransferable transferable  = storable as ITransferable;

            if (transferable != null)
            {
                transferable.TransferTo(this);
            }
            baseReference.UnPinValue();
            reference.ScalabilityCache.Free(reference);
            return(baseReference);
        }
Пример #6
0
        protected internal FileReference FindFileFromItem(ITaskItem item)
        {
            string targetPath = item.GetMetadata(ItemMetadataNames.targetPath);

            if (String.IsNullOrEmpty(targetPath))
            {
                targetPath = BaseReference.GetDefaultTargetPath(item.ItemSpec);
            }
            foreach (FileReference file in _manifest.FileReferences)
            {
                if (String.Compare(targetPath, file.TargetPath, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return(file);
                }
            }
            return(AddFileFromItem(item));
        }
Пример #7
0
        /// <summary>
        /// Ensure that neither SourcePath nor TargetPath is null
        /// </summary>
        /// <param name="reference">Reference object</param>
        public static void EnsurePath(BaseReference reference)
        {
            if (reference.SourcePath == null)
            {
                reference.SourcePath = reference.TargetPath;
            }

            if (reference.TargetPath == null)
            {
                reference.TargetPath = reference.SourcePath;
            }

            if (reference.TargetPath == null)
            {
                reference.TargetPath = reference.SourcePath = "";
            }
        }
Пример #8
0
        protected internal FileReference FindFileFromItem(ITaskItem item)
        {
            string metadata = item.GetMetadata("TargetPath");

            if (string.IsNullOrEmpty(metadata))
            {
                metadata = BaseReference.GetDefaultTargetPath(item.ItemSpec);
            }
            foreach (FileReference reference in this.manifest.FileReferences)
            {
                if (string.Compare(metadata, reference.TargetPath, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return(reference);
                }
            }
            return(this.AddFileFromItem(item));
        }
        private static int GetBaseReferenceIndex(ArrayList list, string fullname)
        {
            int r = -1;

            if ((list != null) && !string.IsNullOrEmpty(fullname))
            {
                int cc = list.Count;
                for (int i = 0; i < cc; ++i)
                {
                    BaseReference fi = list[i] as BaseReference;
                    if (string.Compare(fi.SourcePath, fullname, true) == 0)
                    {
                        r = i;
                        break;
                    }
                }
            }
            return(r);
        }
Пример #10
0
        private void SetItemAttributes(ITaskItem item, BaseReference file)
        {
            string metadata = item.GetMetadata("TargetPath");

            if (!string.IsNullOrEmpty(metadata))
            {
                file.TargetPath = metadata;
            }
            else
            {
                file.TargetPath = (Path.IsPathRooted(file.SourcePath) || file.SourcePath.StartsWith("..", StringComparison.Ordinal)) ? Path.GetFileName(file.SourcePath) : file.SourcePath;
            }
            file.Group      = item.GetMetadata("Group");
            file.IsOptional = !string.IsNullOrEmpty(file.Group);
            if (Util.CompareFrameworkVersions(this.TargetFrameworkVersion, "v3.5") >= 0)
            {
                file.IncludeHash = ConvertUtil.ToBoolean(item.GetMetadata("IncludeHash"), true);
            }
        }
Пример #11
0
        public static void AddBaseReference(WordprocessingDocument document, BaseReference tokenBase)
        {
            _log.Info("Printing Base Properties: " + tokenBase.Reference.Id);
            var body      = document.MainDocumentPart.Document.Body;
            var baseProps = new[, ]
            {
                { "Token Name:", tokenBase.Name },
                { "Symbol:", tokenBase.Symbol },
                { "Owner:", tokenBase.Owner },
                { "Quantity:", tokenBase.Quantity.ToString() },
                { "Decimals:", tokenBase.Decimals.ToString() },
                { "Constructor Name:", tokenBase.ConstructorName }
            };

            var aDef  = body.AppendChild(new Paragraph());
            var adRun = aDef.AppendChild(new Run());

            adRun.AppendChild(new Text("Base Details"));
            Utils.ApplyStyleToParagraph(document, "Heading1", "Heading1", aDef, JustificationValues.Center);
            Utils.AddTable(document, baseProps);

            if (tokenBase.TokenProperties.Count <= 0)
            {
                return;
            }

            var propDef = body.AppendChild(new Paragraph());
            var propRun = propDef.AppendChild(new Run());

            propRun.AppendChild(new Text("Properties:"));
            Utils.ApplyStyleToParagraph(document, "Heading3", "Heading3", propDef);

            var propsPara = body.AppendChild(new Paragraph());
            var propsRun  = propsPara.AppendChild(new Run());

            propsRun.AppendChild(Utils.GetGenericPropertyTable(document, "Name", "Value", tokenBase.TokenProperties));
        }
Пример #12
0
 public bool TryCreateReference(ObjectType referenceObjectType, out BaseReference reference)
 {
     reference = null;
     return(false);
 }
Пример #13
0
 public bool TryCreateReference(IStorable refTarget, out BaseReference reference)
 {
     reference = null;
     return(false);
 }
Пример #14
0
        private ApplicationManifest CreateApplicationManifest(string entryPoint, out string configFileName, out string entryPointFilePath)
        {
            entryPointFilePath = null;
            string frameworkVersion;

            if (string.IsNullOrEmpty(TargetFramework))
            {
                frameworkVersion = "3.5";
            }
            else
            {
                FrameworkName fn = new FrameworkName(TargetFramework);
                frameworkVersion = fn.Version.ToString();
            }
            ApplicationManifest manifest = new ApplicationManifest(frameworkVersion);

            manifest.IsClickOnceManifest = true;
            manifest.IconFile            = IconFile;
            configFileName = null;

            Dictionary <string, AssemblyIdentity> addedIdentities = new Dictionary <string, AssemblyIdentity>();
            string basePath = Path.GetFullPath(BasePath);

            foreach (var taskItem in Files.Where(MatchFilter))
            {
                string        filePath   = taskItem.GetMetadata("FullPath");
                string        targetPath = null;
                string        dir        = Path.GetDirectoryName(filePath);
                string        fileName   = Path.GetFileName(filePath);
                BaseReference reference  = null;
                if (!dir.Equals(basePath, StringComparison.InvariantCultureIgnoreCase) &&
                    dir.StartsWith(basePath, StringComparison.InvariantCultureIgnoreCase))
                {
                    int index = basePath.Length;
                    if (dir[index] == Path.DirectorySeparatorChar)
                    {
                        index++;
                    }

                    targetPath = Path.Combine(dir.Substring(index), fileName);
                }


                AssemblyIdentity identity = null;
                try
                {
                    identity = AssemblyIdentity.FromFile(filePath);
                    if (LinkAssembliesWithManifestAsFile && HasEmbeddedManifest(filePath))
                    {
                        identity = null;
                    }
                }
                catch (BadImageFormatException)
                {
                }

                if (identity != null)
                {
                    string identityFullName = identity.GetFullName(AssemblyIdentity.FullNameFlags.All);
                    if (addedIdentities.ContainsKey(identityFullName))
                    {
                        throw new DuplicateAssemblyReferenceException(identityFullName);
                    }
                    else
                    {
                        addedIdentities.Add(identityFullName, identity);
                    }

                    AssemblyReference asmRef = new AssemblyReference(fileName);
                    reference = asmRef;
                    asmRef.AssemblyIdentity = identity;
                    manifest.AssemblyReferences.Add(asmRef);
                    if (manifest.EntryPoint == null &&
                        (string.IsNullOrEmpty(entryPoint) || string.Equals(entryPoint, fileName, StringComparison.InvariantCultureIgnoreCase)) &&
                        Path.GetExtension(fileName).Equals(".exe", StringComparison.InvariantCultureIgnoreCase))
                    {
                        configFileName     = SetEntryPointAndConfig(manifest, filePath, asmRef);
                        entryPointFilePath = filePath;
                    }
                }
                else
                {
                    FileReference fileRef = new FileReference(fileName);
                    reference = fileRef;
                    manifest.FileReferences.Add(fileRef);
                }

                Log.LogMessage(MessageImportance.Low, "TargetPath for {0}: {1}", fileName, targetPath);
                reference.TargetPath = targetPath;
            }

            List <string> searchPaths = new List <string>();

            searchPaths.Add(BasePath);
            if (ConfigFile != null)
            {
                searchPaths.Add(Path.GetDirectoryName(ConfigFile.ItemSpec));
            }
            manifest.ResolveFiles(searchPaths.ToArray());
            manifest.UpdateFileInfo();

            TrustInfo trust = new TrustInfo();

            trust.IsFullTrust  = true;
            manifest.TrustInfo = trust;
            if (manifest.EntryPoint == null)
            {
                Log.LogError("Cannot determine EntryPoint. EntryPoint property = '{0}'", entryPoint ?? string.Empty);
            }

            return(manifest);
        }
Пример #15
0
 internal static void OutputBaseReference(BaseReference baseType)
 {
     Log.Warn("	***Base Token Reference***");
     OutputArtifactReference(baseType.Reference);
     Log.Warn("	***Base Token Reference End***");
 }
Пример #16
0
 public void Reinstance()
 {
     BaseReference.OnDestroy(this);
     BaseReference.OnCreate(this);
 }