public RelationCollectionForm(Table parentTable, ReferenceCollection referenceCollection) : this() { _referenceCollection = referenceCollection; _originalReferenceCollection = new ReferenceCollection(parentTable.Root, parentTable, ReferenceType.Relation); _originalReferenceCollection.AddRange((ICollection)referenceCollection); _parentTable = parentTable; lvwMembers.Columns.Clear(); lvwMembers.Columns.Add(new ColumnHeader() { Text = "Parent", Width = 200 }); lvwMembers.Columns.Add(new ColumnHeader() { Text = "Child", Width = 200 }); lvwMembers.Columns.Add(new ColumnHeader() { Text = "Role", Width = 200 }); lvwMembers.ListViewItemSorter = new nHydrate.Generator.Common.Forms.CommonLibrary.ListViewItemComparer(0, lvwMembers.Sorting); lvwMembers.Sort(); this.LoadList(); }
/// <summary> /// Builds a DeploymentResource for the release and environment passed, allows you to directly pass the list of skipped steps /// </summary> /// <param name="octRepository">The repository to call against.</param> /// <param name="release">Release to deploy.</param> /// <param name="environment">Environment to deploy to.</param> /// <param name="comment">Comment for the deployment.</param> /// <param name="formValues">Form value variable dictionary.</param> /// <param name="guidedFailure">Enable Guided Failure.</param> /// <param name="skippedSteps">Steps to skip.</param> /// <param name="dateToDeploy">Deployment Date.</param> /// <returns>DeploymentResource</returns> public static DeploymentResource BuildDeployment(OctopusRepository octRepository, ReleaseResource release, EnvironmentResource environment, string comment, Dictionary <string, string> formValues, bool guidedFailure, ReferenceCollection skippedSteps, DateTimeOffset?dateToDeploy) { var machineIDs = new ReferenceCollection(); var releaseTemplate = octRepository.Releases.GetTemplate(release); var deploymentPromotionTarget = releaseTemplate.PromoteTo.SingleOrDefault(x => x.Id.Equals(environment.Id, StringComparison.OrdinalIgnoreCase)); var deploymentPreview = octRepository.Releases.GetPreview(deploymentPromotionTarget); foreach (var element in deploymentPreview.Form.Elements) { var variableInput = element.Control as VariableValue; if (variableInput != null) { var variableValue = formValues[variableInput.Label] ?? formValues[variableInput.Name]; if (string.IsNullOrWhiteSpace(variableValue) && element.IsValueRequired) { throw new ArgumentException(string.Format(ErrorStrings.MissingRequiredVar, variableInput.Label ?? variableInput.Name, ResourceStrings.FormValuesArgException)); } } } var deploymentResource = new DeploymentResource { EnvironmentId = environment.Id, SkipActions = skippedSteps, ReleaseId = release.Id, ForcePackageDownload = false, UseGuidedFailure = guidedFailure, SpecificMachineIds = machineIDs, ForcePackageRedeployment = true, FormValues = formValues, QueueTime = dateToDeploy, Comments = comment }; return(deploymentResource); }
public DashboardConfigurationResource() { IncludedProjectIds = new ReferenceCollection(); IncludedEnvironmentIds = new ReferenceCollection(); IncludedTenantIds = new ReferenceCollection(); IncludedTenantTags = new ReferenceCollection(); }
public MachineResource() { EnvironmentIds = new ReferenceCollection(); Roles = new ReferenceCollection(); TenantTags = new ReferenceCollection(); TenantIds = new ReferenceCollection(); }
public ReferenceCollection GetReferences(ITreeNode element, ReferenceCollection oldReferences) { if (ResolveUtil.CheckThatAllReferencesBelongToElement <MonoScriptReference>(oldReferences, element)) { return(oldReferences); } if (!(element is IPlainScalarNode guidValue)) { return(ReferenceCollection.Empty); } // m_Script: {fileID: 11500000, guid: xxx, type: x} var guidEntry = FlowMapEntryNavigator.GetByValue(guidValue); var flowIDMap = FlowMappingNodeNavigator.GetByEntrie(guidEntry); var blockMappingEntry = BlockMappingEntryNavigator.GetByValue(flowIDMap); if (guidEntry?.Key.MatchesPlainScalarText("guid") == true && blockMappingEntry?.Key.MatchesPlainScalarText("m_Script") == true) { var fileID = flowIDMap.AsFileID(); if (fileID != null && !fileID.IsNullReference && fileID.IsMonoScript) { var metaGuidCache = element.GetSolution().GetComponent <MetaFileGuidCache>(); var reference = new MonoScriptReference(guidValue, fileID, metaGuidCache); return(new ReferenceCollection(reference)); } } return(ReferenceCollection.Empty); }
public static object Deserialize(this JToken data, ReferenceCollection references, object existingValue = default) { if (data.Type == JTokenType.Null) { return(null); } if (data.Type == JTokenType.Integer) { if (references.TryGetReferenceByID(data.Value <long>(), out var r)) { if (r.Object is object obj) { return(obj); } else { r.Deserialize(references, existingValue); return(r.Object); } } else { throw new ArgumentOutOfRangeException(); } } else if (data.Type == JTokenType.String) { string[] s = Regex.Split(data.Value <string>(), @"^\[(.+)PublicKeyToken=(\w+)\]\[(.+)\]$"); return(FromType(TypeEditionHelper.FromString($"{s[1]}PublicKeyToken={s[2]}")).DeserializeCore(s[3], references, existingValue)); } else { throw new ArgumentOutOfRangeException(); } }
public Symbol(string name) { this.Name = name ?? Grammar.UnnamedTokenName; this._productions = new ReferenceCollection<Production>(); this.LocalContextProvider = new ForeignContextProvider(); this.Joint = new Joint(); }
public ReferenceCollection GetReferences(ITreeNode element, ReferenceCollection oldReferences) { if (ResolveUtil.CheckThatAllReferencesBelongToElement <UnityEventTargetReference>(oldReferences, element)) { return(oldReferences); } if (!(element is IPlainScalarNode methodNameValue)) { return(ReferenceCollection.Empty); } // E.g. element is the m_MethodName scalar value "ButtonClickedHandler" in this structure: // m_OnClick: // m_PersistentCalls: // m_Calls: // - m_Target: {fileID: 1870695363} // m_MethodName: ButtonClickedHandler // m_Mode: 3 // m_Arguments: // m_ObjectArgument: {fileID: 0} // m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine // m_IntArgument: 1 // m_FloatArgument: 0 // m_StringArgument: // m_BoolArgument: 0 // m_CallState: 2 // m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, // Culture=neutral, PublicKeyToken=null var methodNameMapEntry = BlockMappingEntryNavigator.GetByValue(methodNameValue); var callMapNode = BlockMappingNodeNavigator.GetByEntrie(methodNameMapEntry); var callsSequenceEntry = SequenceEntryNavigator.GetByValue(callMapNode); var callsSequenceNode = BlockSequenceNodeNavigator.GetByEntrie(callsSequenceEntry); var callsMapEntry = BlockMappingEntryNavigator.GetByValue(callsSequenceNode); // callsMapEntry should be "m_Calls" (and contain a value that is a sequence node). If it's not null, // everything else is also not null if (callsMapEntry == null) { return(ReferenceCollection.Empty); } if (methodNameMapEntry.Key.MatchesPlainScalarText("m_MethodName") && callsMapEntry.Key.MatchesPlainScalarText("m_Calls")) { // If we have a guid, that means this event handler exists inside another asset. That asset might be // a .dll, in which case we don't want to add a reference (the primary purpose of these references // is to enable Find Usages of methods, not navigation *from* YAML). Or it might be e.g. a prefab. // This would be a reference to a prefab that contains a MonoScript asset that has the method // TODO: Create an index of other assets that we could target var fileID = callMapNode.FindMapEntryBySimpleKey("m_Target")?.Value.AsFileID(); if (fileID != null && !fileID.IsNullReference && fileID.guid == null) { var reference = new UnityEventTargetReference(methodNameValue, fileID); return(new ReferenceCollection(reference)); } } return(ReferenceCollection.Empty); }
private IDictionary <string, List <string> > ToFriendlyTags(ReferenceCollection tenantTags) { var tagSets = new Dictionary <string, List <string> >(); foreach (var rawTag in tenantTags) { // rawTags come in strings like "MyTagSet/MyTag". So we are splitting them here to get the separated values. //[0] will be the TagSet and [1] will be the tag var splitTag = rawTag.Split('/'); var tagset = splitTag[0]; var tag = splitTag[1]; if (!tagSets.ContainsKey(tagset)) { tagSets.Add(tagset, new List <string>() { tag }); } else { tagSets[tagset].Add(tag); } } return(tagSets); }
public Symbol(string name) { this.Name = name ?? Grammar.UnnamedTokenName; this._productions = new ReferenceCollection <Production>(); this.LocalContextProvider = new ForeignContextProvider(); this.Joint = new Joint(); }
public AssemblyName(IAssemblyName name, IApplicationContext ctxt) { this._name = name; this._ctxt = ctxt; Properties = new PropertyCollection(this); References = new ReferenceCollection(this); }
public static IEnumerable <Task <ElementReference> > ToModel <TResource>(this ReferenceCollection collection, IGet <TResource> repository) where TResource : INamedResource { return(collection.Select(async id => { var resource = await repository.Get(id); return new ElementReference(resource.Name); })); }
public static void UpdateWith(this ReferenceCollection collection, IEnumerable <string> ids) { collection.Clear(); foreach (var id in ids) { collection.Add(id); } }
public void CheckForResolveProblems(ITreeNode node, IHighlightingConsumer consumer, ReferenceCollection references) { foreach (var reference in references) { CheckForResolveProblems(consumer, reference); } }
public ReferenceCollection GetReferences(ITreeNode element, ReferenceCollection oldReferences) { return(element is SpringNodeIdentifier variable ? new ReferenceCollection(new ArrayList <IReference> { new SpringIdentifierReference(variable) }) : ReferenceCollection.Empty); }
public void CreateAndRemoveMachine() { #region MachineCreate var environmentId = TestUtilities.Repository.Environments.FindAll().FirstOrDefault().Id; var resource = new MachineResource() { Name = TestResourceName, Endpoint = new OfflineDropEndpointResource() { ApplicationsDirectory = "SomePath", DropFolderPath = "SomePath", OctopusWorkingDirectory = "SomePath" }, EnvironmentIds = ReferenceCollection.One(environmentId), Roles = ReferenceCollection.One("WebServer"), }; var createParameters = new List <CmdletParameter> { new CmdletParameter() { Name = "Resource", Resource = resource } }; var createPowershell = new CmdletRunspace().CreatePowershellcmdlet(CreateCmdletName, CreateCmdletType, createParameters); //The fact that the line below doesn't throw is enough to prove that the cmdlet returns the expected object type really. Couldn't figure out a way to make the assert around the Powershell.invoke call var createResult = createPowershell.Invoke <MachineResource>().FirstOrDefault(); if (createResult != null) { Assert.AreEqual(createResult.Name, TestResourceName); Console.WriteLine("Created resource [{0}] of type [{1}]", createResult.Name, createResult.GetType()); } #endregion #region MachineDelete var removeParameters = new List <CmdletParameter> { new CmdletParameter() { Name = "Resource", Resource = createResult } }; var removePowershell = new CmdletRunspace().CreatePowershellcmdlet(RemoveCmdletName, RemoveCmdletType); var removeResult = removePowershell.Invoke <bool>(removeParameters).FirstOrDefault(); Assert.IsTrue(removeResult); Console.WriteLine("Deleted resource [{0}] of type [{1}]", createResult.Name, createResult.GetType()); #endregion }
protected ProjectItem([NotNull] IProject project, [NotNull] ISnapshot snapshot, [NotNull] ProjectItemUri uri) { Project = project; Uri = uri; Snapshots.Add(snapshot); References = new ReferenceCollection(this); }
public InvitationResource Invite(ReferenceCollection addToTeamIds) { var invitationResource = new InvitationResource { AddToTeamIds = addToTeamIds ?? new ReferenceCollection() }; EnrichSpaceId(invitationResource); return(Create(invitationResource)); }
/// <summary> /// 获取对象池合集 /// </summary> /// <param name="referenceType"></param> /// <returns></returns> private static ReferenceCollection GetReferenceCollection(Type referenceType) { ReferenceCollection referenceCollection = null; lock (_referenceCollections) { _referenceCollections.TryGetValue(referenceType, out referenceCollection); } return(referenceCollection); }
public CustomView(INHydrateModelObject root) : base(root) { _columns = new ReferenceCollection(this.Root, this, ReferenceType.CustomViewColumn); _columns.ResetKey(Guid.Empty.ToString()); _columns.ObjectPlural = "Fields"; _columns.ObjectSingular = "Field"; _columns.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderClose); _columns.SelectedImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderOpen); }
public ReferenceCollection GetReferences(ITreeNode element, ReferenceCollection oldReferences) { if (element is SpringVariableReferenceElement varReference) { return(new ReferenceCollection(new ArrayList <IReference> { new SpringVariableReference(varReference) })); } return(ReferenceCollection.Empty); }
//private DateTime _createdDate = DateTime.Now; #endregion #region Constructor public CustomRetrieveRule(INHydrateModelObject root) : base(root) { _parameters = new ReferenceCollection(this.Root, this, ReferenceType.Parameter); _parameters.ObjectPlural = "Parameters"; _parameters.ObjectSingular = "Parameter"; _parameters.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderClose); _parameters.SelectedImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderOpen); }
/// <summary> /// 向引用池中追加指定数量的引用。 /// </summary> /// <param name="referenceType">引用类型。</param> /// <param name="count">追加数量。</param> public static void Add(Type referenceType, int count) { InternalCheckReferenceType(referenceType); ReferenceCollection referenceCollection = GetReferenceCollection(referenceType.FullName); while (count-- > 0) { referenceCollection.Release((IReference)Activator.CreateInstance(referenceType)); } }
public override void Write(object target, object value) { var collection = base.Read(target) as ReferenceCollection; if (collection == null) { base.Write(target, collection = new ReferenceCollection()); } collection.ReplaceAll(Parse(value?.ToString())); }
public ReferenceCollection GetReferences(ITreeNode element, ReferenceCollection oldReferences) { if (element is SpringReferenceNodeElement reference) { return(new ReferenceCollection(new List <IReference> { new SpringReference(reference) })); } return(ReferenceCollection.Empty); }
// returns true if there is an active data reader on the specified command internal bool HasLiveReader(OleDbCommand cmd) { OleDbDataReader reader = null; if (null != ReferenceCollection) { reader = ReferenceCollection.FindItem <OleDbDataReader>(OleDbReferenceCollection.DataReaderTag, (dataReader) => cmd == dataReader.Command); } return(reader != null); }
public ReferenceCollection GetReferences(ITreeNode element, ReferenceCollection oldReferences) { if (!(element is VarNode)) { return(ReferenceCollection.Empty); } return(new ReferenceCollection(new List <IReference> { new VarReference((VarNode)element) })); }
public ReferenceCollection GetReferences(ITreeNode element, ReferenceCollection oldReferences) { if (element is PascalVariable variable) { return(new ReferenceCollection(new ArrayList <IReference> { new PascalVariableReference(variable) })); } return(ReferenceCollection.Empty); }
public static Column GetColumnByKey(ReferenceCollection referenceCollection, string columnKey) { foreach (var column in referenceCollection.Where(x => x.Object is Column).Select(x => x.Object as Column)) { if (string.Compare(column.Key, columnKey, true) == 0) { return(column); } } return(null); }
public SecurityFunction(INHydrateModelObject root, Table parent) : base(root) { _parent = parent; _parameters = new ReferenceCollection(this.Root, this, ReferenceType.Parameter); _parameters.ResetKey(Guid.Empty.ToString()); _parameters.ObjectPlural = "Parameters"; _parameters.ObjectSingular = "Parameter"; _parameters.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderClose); _parameters.SelectedImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderOpen); }
public override ReferenceCollection GetReferences(ITreeNode element, ReferenceCollection oldReferences) { if (ResolveUtil.CheckThatAllReferencesBelongToElement <UnityEventFunctionReference>(oldReferences, element)) { return(oldReferences); } var literal = GetValidStringLiteralExpression(element); if (literal == null) { return(ReferenceCollection.Empty); } if (!IsFirstArgumentInMethod(literal)) { return(ReferenceCollection.Empty); } var invocationExpression = literal.GetContainingNode <IInvocationExpression>(); var invocationReference = invocationExpression?.Reference; var invokedMethod = invocationReference?.Resolve().DeclaredElement as IMethod; if (invokedMethod == null) { return(ReferenceCollection.Empty); } var isInvokedFunction = ourInvokeMethodNames.Contains(invokedMethod.ShortName); var isCoroutine = IsCoroutine(invokedMethod); if (isInvokedFunction || isCoroutine) { var containingType = invokedMethod.GetContainingType(); if (containingType != null && Equals(containingType.GetClrName(), KnownTypes.MonoBehaviour)) { var targetType = invocationExpression.ExtensionQualifier?.GetExpressionType() .ToIType()?.GetTypeElement() ?? literal.GetContainingNode <IMethodDeclaration>()? .DeclaredElement?.GetContainingType(); if (targetType != null) { var methodSignature = GetMethodSignature(invocationExpression, invokedMethod, isCoroutine); var reference = new UnityEventFunctionReference(targetType, literal, methodSignature); return(new ReferenceCollection(reference)); } } } return(ReferenceCollection.Empty); }
private static RefState TryResolveReference(out Reference reference, ReferenceCollection refsColl, string canonicalName) { if (!Reference.IsValidName(canonicalName)) { reference = null; return RefState.DoesNotLookValid; } reference = refsColl[canonicalName]; return reference != null ? RefState.Exists : RefState.DoesNotExistButLooksValid; }
public TableComponent(INHydrateModelObject root, Table parent) : base(root) { _parent = parent; _columns = new ReferenceCollection(this.Root, this, ReferenceType.Column); _columns.ObjectPlural = "Fields"; _columns.ObjectSingular = "Field"; _columns.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderClose); _columns.SelectedImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderOpen); }
public static void Release <T>(T obj) where T : class, new() { OnRelease(obj); Type classType = obj.GetType(); ReferenceCollection referenceItem; if (!Pools.TryGetValue(classType, out referenceItem)) { referenceItem = new ReferenceCollection(); Pools.Add(classType, referenceItem); } referenceItem.SetItem(obj); }
/// <summary> /// 创建对象池合集 /// </summary> /// <param name="referenceType"></param> /// <returns></returns> private static bool CreateReferenceCollection(Type referenceType) { ReferenceCollection referenceCollection = null; if (_referenceCollections.TryGetValue(referenceType, out referenceCollection) == true) { FrameworkLog.ErrorFormat("对象池已存在. referenceType:" + referenceType); return(false); } referenceCollection = new ReferenceCollection(referenceType.Name); _referenceCollections.Add(referenceType, referenceCollection); return(true); }
public CodeDirectory(string name, string path) { if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name"); if (string.IsNullOrEmpty(path)) throw new ArgumentNullException("path"); Name = name; Path = path; files = new List<IFile>(); directories = new List<CodeDirectory>(); Files = files; Directories = directories; References = new ReferenceCollection(); }
/// <summary> /// 从引用池获取引用 /// </summary> /// <typeparam name="T">引用类型。</typeparam> /// <returns>引用。</returns> public static T Take <T>() where T : class, IReference, new() { System.Type referenceType = typeof(T); ReferenceCollection referenceCollection = GetReferenceCollection(referenceType); if (referenceCollection == null) { CreateReferenceCollection(referenceType); referenceCollection = GetReferenceCollection(referenceType); } return(referenceCollection.Take <T>()); }
static void AddMissingReferencesToReferenceCollection(XDocument projectFile, ReferenceCollection references) { var referencesInProject = from project in projectFile.Elements() from itemGroup in project.Elements(Msbuild.DefaultNamespace + "ItemGroup") from refElement in itemGroup.Elements() where refElement.Name == Msbuild.DefaultNamespace + "Reference" || refElement.Name == Msbuild.DefaultNamespace + "ProjectReference" select CreateReference(refElement); var newReferences = referencesInProject.Except(references).ToArray(); newReferences.Each(references.Add); }
private static List <LifecycleResource> CreateLifecycles() { CreateEnvironments();//Start by creating the environments that will be added to the repository //Create the rest of the lifecycles for test var lifecycleList = new List <LifecycleResource>(); foreach (var lifecycleName in LifecycleNames) { var lifecycle = _repository.Lifecycles.FindByName(lifecycleName).Result ?? new LifecycleResource(); lifecycle.Name = lifecycleName; lifecycle.Description = GeneralResourceProperty.ResourceDescription; if (lifecycle.Name == "Default Lifecycle") { lifecycle.Phases.Clear(); for (int i = 0; i < EnvironmentNames.Length; i++) { var environment = _repository.Environments.FindByName(EnvironmentNames[i]).Result; var phase = new PhaseResource() { Name = environment.Name, IsOptionalPhase = false, OptionalDeploymentTargets = ReferenceCollection.One(environment.Id) }; lifecycle.Phases.Insert(i, phase); } } try { Log.Information($"Creating/Modifying Lifecycle [{lifecycle.Name}]"); lifecycleList.Add(lifecycle.Id == null ? _repository.Lifecycles.Create(lifecycle).Result : _repository.Lifecycles.Modify(lifecycle).Result ); } catch (Exception e) { Console.WriteLine(e); throw; } } return(lifecycleList); }
public static Column GetColumnByName(ReferenceCollection referenceCollection, string name) { foreach (Reference r in referenceCollection) { if (r.Object is Column) { if (string.Compare(((Column)r.Object).Name, name, true) == 0) { return((Column)r.Object); } } } return(null); }
public static Column GetColumnByKey(ReferenceCollection referenceCollection, string columnKey) { foreach (Reference r in referenceCollection) { if (r.Object is Column) { if (string.Compare(((Column)r.Object).Key, columnKey, true) == 0) { return((Column)r.Object); } } } return(null); }
/// <summary> /// Associates the object with a server (mandatory) and its model parent (optional). /// </summary> protected NodeSource( IServerInternal server, NodeSource parent) { if (server == null) throw new ArgumentNullException("server"); m_server = server; m_parent = parent; m_references = new ReferenceCollection(); if (parent != null) { m_lock = parent.m_lock; parent.AddChild(this); } }
public ColumnCodeFacadeUpdateForm(ReferenceCollection columnCollection, ModelRoot modelRoot, FieldSettingConstants fieldSetting) : this() { _columnCollection = columnCollection; _modelRoot = modelRoot; _fieldSetting = fieldSetting; if (_fieldSetting == FieldSettingConstants.Name) { this.Text = "Update Field"; } else if (_fieldSetting == FieldSettingConstants.Name) { this.Text = "Update CodeFacade"; } try { ModelCacheFile cacheFile = null; if (modelRoot != null) cacheFile = new ModelCacheFile(modelRoot.GeneratorProject); else cacheFile = new ModelCacheFile(((ModelRoot)columnCollection.Root).GeneratorProject); if (!string.IsNullOrEmpty(cacheFile.CodeFacadeSettings)) { var document = new XmlDocument(); document.LoadXml(cacheFile.CodeFacadeSettings); var containerNode = document.DocumentElement.ChildNodes[0]; optPrefix.Checked = XmlHelper.GetAttributeValue(containerNode, "prefixChecked", optPrefix.Checked); txtPrefix.Text = XmlHelper.GetAttributeValue(containerNode, "prefix", txtPrefix.Text); chkReplaceText.Checked = XmlHelper.GetAttributeValue(containerNode, "replaceText", chkReplaceText.Checked); txtReplaceSource.Text = XmlHelper.GetAttributeValue(containerNode, "replaceSource", txtReplaceSource.Text); txtReplaceTarget.Text = XmlHelper.GetAttributeValue(containerNode, "replaceTarget", txtReplaceTarget.Text); optUpcase.Checked = XmlHelper.GetAttributeValue(containerNode, "upcase", optUpcase.Checked); optUnderscore.Checked = XmlHelper.GetAttributeValue(containerNode, "underscore", optUnderscore.Checked); chkSkip2Caps.Checked = XmlHelper.GetAttributeValue(containerNode, "TwoCaps", chkSkip2Caps.Checked); } } catch (Exception ex) { throw; } this.UpdateForm(); }
/// <summary> /// Initializes a new instance of the <see cref = "Repository" /> class. /// <para>For a standard repository, <paramref name="path"/> should point to the ".git" folder. For a bare repository, <paramref name="path"/> should directly point to the repository folder.</para> /// </summary> /// <param name = "path">The path to the git repository to open.</param> public Repository(string path) { Ensure.ArgumentNotNullOrEmptyString(path, "path"); var res = NativeMethods.git_repository_open(out handle, PosixPathHelper.ToPosix(path)); Ensure.Success(res); isBare = NativeMethods.git_repository_is_bare(handle); if (!isBare) { index = new Index(this); } commits = new CommitCollection(this); refs = new ReferenceCollection(this); branches = new BranchCollection(this); tags = new TagCollection(this); }
/// <summary> /// Initializes a new instance of the <see cref = "Repository" /> class. /// <para>For a standard repository, <paramref name="path"/> should point to the ".git" folder. For a bare repository, <paramref name="path"/> should directly point to the repository folder.</para> /// </summary> /// <param name = "path">The path to the git repository to open.</param> public Repository(string path) { Ensure.ArgumentNotNullOrEmptyString(path, "path"); var res = NativeMethods.git_repository_open(out handle, PosixPathHelper.ToPosix(path)); Ensure.Success(res); string normalizedPath = NativeMethods.git_repository_path(handle).MarshallAsString(); string normalizedWorkDir = NativeMethods.git_repository_workdir(handle).MarshallAsString(); Info = new RepositoryInformation(this, normalizedPath, normalizedWorkDir, normalizedWorkDir == null); if (!Info.IsBare) index = new Index(this); commits = new CommitCollection(this); refs = new ReferenceCollection(this); branches = new BranchCollection(this); tags = new TagCollection(this); }
public DocProcessor(string fileName, ReferenceCollection refs, ReferenceOrder order) { if (fileName.IsNullOrBlank()) throw new ArgumentException("fileName"); if (refs.IsNullOrEmpty()) throw new ArgumentException("refs"); _word = new Application {Visible = false}; _refs = refs; _order = order; try { _doc = _word.Documents.Open(fileName, ReadOnly: true); } catch(Exception ex) { throw new Exception("Error opening Word document", ex); } _rep = new ReferenceReplacer(_doc.Content.Text, ref _refs, _order); }
public static void Convert(DocumentNode document, Stream ostream) { if(null == document) throw Xception.Because.ArgumentNull(() => document); var references = new ReferenceCollection(document); using(var xmlWriter = XmlWriter.Create(ostream, new XmlWriterSettings { CloseOutput = false, Indent = true, IndentChars = "\t", NewLineChars = "\n", OmitXmlDeclaration = true })) { xmlWriter.WriteDocType("html", null, null, null); xmlWriter.WriteStartElement("html"); xmlWriter.WriteStartElement("body"); document.HandleWith(new XmlWritingNodeHandler(xmlWriter, references)); xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); } }
public static Column GetColumnByKey(ReferenceCollection referenceCollection, string columnKey) { foreach (Reference r in referenceCollection) { if (r.Object is Column) { if (string.Compare(((Column)r.Object).Key, columnKey, true) == 0) return (Column)r.Object; } } return null; }
public ReferenceReplacer(string text, ref ReferenceCollection references, ReferenceOrder order) { _usedReferences = new ReferenceCollection(); _badIds = new HashSet<string>(); _unknownIds = new HashSet<int>(); _unknownTags = new HashSet<string>(); _replacements = new Dictionary<string, Reference[]>(); var re = new Regex(@"\[\[(([" + RefIdPrefix + @"\d\w\s" + RefDelimiter + @"]+)?)\]\]", RegexOptions.IgnoreCase); foreach (Match match in re.Matches(text)) { var refText = match.Groups[0].Captures[0].Value; var refList = match.Groups[1].Captures[0].Value; if (_replacements.ContainsKey(refText)) continue; var parts = refList.Split(new[] {RefDelimiter}, StringSplitOptions.RemoveEmptyEntries); if (parts.Length < 1) { // Replacements with no references supposed to be deleted from document _replacements.Add(refText, null); continue; } var refs = new HashSet<Reference>(); foreach (var part in parts.Select(part => part.Trim()).Where(p => p.Length != 0)) { Reference reference; if (part[0] == '#') { int id; if (!Int32.TryParse(part.Substring(1), NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, CultureInfo.InvariantCulture, out id)) { _badIds.Add(part); continue; } reference = references.GetById(id); if (reference == null) { _unknownIds.Add(id); continue; } } else { reference = references.GetByTag(part); if (reference == null) { _unknownTags.Add(part); continue; } } refs.Add(reference); if (!_usedReferences.Contains(reference)) { _usedReferences.Add(reference); } } _replacements.Add(refText, refs.ToArray()); } _usedReferences.Sort(order); for (var i = 0; i < _usedReferences.Count; i++) { _usedReferences[i].RefNum = i + 1; } }
public static Column GetColumnByName(ReferenceCollection referenceCollection, string name) { foreach (Reference r in referenceCollection) { if (r.Object is Column) { if (string.Compare(((Column)r.Object).Name, name, true) == 0) return (Column)r.Object; } } return null; }
public ProduireGetMemberBinder(string name, ReferenceCollection reference) : base(name) { _reference = reference; }
private async Task<DeploymentResource> CreateDeploymentTask(ProjectResource project, ReleaseResource release, DeploymentPromotionTarget promotionTarget, ReferenceCollection specificMachineIds, TenantResource tenant = null) { var preview = await Repository.Releases.GetPreview(promotionTarget).ConfigureAwait(false); // Validate skipped steps var skip = new ReferenceCollection(); foreach (var step in SkipStepNames) { var stepToExecute = preview.StepsToExecute.SingleOrDefault(s => string.Equals(s.ActionName, step, StringComparison.CurrentCultureIgnoreCase)); if (stepToExecute == null) { Log.Warning("No step/action named '{Step:l}' could be found when deploying to environment '{Environment:l}', so the step cannot be skipped.", step, promotionTarget.Name); } else { Log.Debug("Skipping step: {Step:l}", stepToExecute.ActionName); skip.Add(stepToExecute.ActionId); } } // Validate form values supplied if (preview.Form != null && preview.Form.Elements != null && preview.Form.Values != null) { foreach (var element in preview.Form.Elements) { var variableInput = element.Control as VariableValue; if (variableInput == null) { continue; } var value = variables.Get(variableInput.Label) ?? variables.Get(variableInput.Name); if (string.IsNullOrWhiteSpace(value) && element.IsValueRequired) { throw new ArgumentException("Please provide a variable for the prompted value " + variableInput.Label); } preview.Form.Values[element.Name] = value; } } // Log step with no machines foreach (var previewStep in preview.StepsToExecute) { if (previewStep.HasNoApplicableMachines) { Log.Warning("Warning: there are no applicable machines roles used by step {Step:l}", previewStep.ActionName); } } var deployment = await Repository.Deployments.Create(new DeploymentResource { TenantId = tenant?.Id, EnvironmentId = promotionTarget.Id, SkipActions = skip, ReleaseId = release.Id, ForcePackageDownload = ForcePackageDownload, UseGuidedFailure = UseGuidedFailure.GetValueOrDefault(preview.UseGuidedFailureModeByDefault), SpecificMachineIds = specificMachineIds, ForcePackageRedeployment = ForcePackageRedeployment, FormValues = (preview.Form ?? new Form()).Values, QueueTime = DeployAt == null ? null : (DateTimeOffset?) DeployAt.Value }) .ConfigureAwait(false); Log.Information("Deploying {Project:l} {Release:} to: {PromotionTarget:l} {Tenant:l}(Guided Failure: {GuidedFailure:l})", project.Name, release.Version, promotionTarget.Name, tenant == null ? string.Empty : $"for {tenant.Name} ", deployment.UseGuidedFailure ? "Enabled" : "Not Enabled"); return deployment; }
private async Task<ReferenceCollection> GetSpecificMachines() { var specificMachineIds = new ReferenceCollection(); if (SpecificMachineNames.Any()) { var machines = await Repository.Machines.FindByNames(SpecificMachineNames).ConfigureAwait(false); var missing = SpecificMachineNames.Except(machines.Select(m => m.Name), StringComparer.OrdinalIgnoreCase).ToList(); if (missing.Any()) { throw new CommandException("The following specific machines could not be found: " + missing.ReadableJoin()); } specificMachineIds.AddRange(machines.Select(m => m.Id)); } return specificMachineIds; }
public ProjectConnectivityPolicy() { TargetRoles = new ReferenceCollection(); }
public Table(INHydrateModelObject root) : base(root) { this.MetaData = new MetadataItemCollection(); _compositeList = new TableCompositeCollection(root, this); _componentList = new TableComponentCollection(root, this); _security = new SecurityFunction(root, this); _security.ResetKey(Guid.Empty.ToString()); _staticData = new RowEntryCollection(this.Root); _columns = new ReferenceCollection(this.Root, this, ReferenceType.Column); _columns.ResetKey(Guid.Empty.ToString()); _customRetrieveRules = new ReferenceCollection(this.Root, this, ReferenceType.CustomRetrieveRule); _customRetrieveRules.ResetKey(Guid.Empty.ToString()); _relationships = new ReferenceCollection(this.Root, this, ReferenceType.Relation); _relationships.ResetKey(Guid.Empty.ToString()); _viewRelationships = new ReferenceCollection(this.Root, this, ReferenceType.Relation); _viewRelationships.ResetKey(Guid.Empty.ToString()); _columns.ObjectPlural = "Fields"; _columns.ObjectSingular = "Field"; _columns.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderClose); _columns.SelectedImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderOpen); _customRetrieveRules.ObjectPlural = "RetrieveRules"; _customRetrieveRules.ObjectSingular = "RetrieveRule"; _customRetrieveRules.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderClose); _customRetrieveRules.SelectedImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderOpen); _relationships.ObjectPlural = "Relationships"; _relationships.ObjectSingular = "Relationship"; _relationships.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderClose); _relationships.SelectedImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderOpen); _viewRelationships.ObjectPlural = "View Relationships"; _viewRelationships.ObjectSingular = "View Relationship"; _viewRelationships.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderClose); _viewRelationships.SelectedImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderOpen); }
public void DeployRelease(ProjectResource project, ReleaseResource release, List<string> environments) { if (environments.Count == 0) return; var deployments = new List<DeploymentResource>(); var deploymentTasks = new List<TaskResource>(); var releaseTemplate = Repository.Releases.GetTemplate(release); var promotingEnvironments = (from environment in environments.Distinct(StringComparer.CurrentCultureIgnoreCase) let promote = releaseTemplate.PromoteTo.FirstOrDefault(p => string.Equals(p.Name, environment)) select new {Name = environment, Promote = promote}).ToList(); var unknownEnvironments = promotingEnvironments.Where(p => p.Promote == null).ToList(); if (unknownEnvironments.Count > 0) { throw new CommandException(string.Format("Release '{0}' of project '{1}' cannot be deployed to {2} not in the list of environments that this release can be deployed to. This may be because a) the environment does not exist, b) the name is misspelled, c) you don't have permission to deploy to this environment, or d) the environment is not in the list of environments defined by the project group.", release.Version, project.Name, unknownEnvironments.Count == 1 ? "environment '" + unknownEnvironments[0].Name + "' because the environment is" : "environments " + string.Join(", ", unknownEnvironments.Select(e => "'" + e.Name + "'")) + " because the environments are" )); } var specificMachineIds = new ReferenceCollection(); if (SpecificMachineNames.Any()) { var machines = Repository.Machines.FindByNames(SpecificMachineNames); var missing = SpecificMachineNames.Except(machines.Select(m => m.Name), StringComparer.OrdinalIgnoreCase).ToList(); if (missing.Any()) { throw new CommandException("The following specific machines could not be found: " + missing.ReadableJoin()); } specificMachineIds.AddRange(machines.Select(m => m.Id)); } foreach (var environment in promotingEnvironments) { var promote = environment.Promote; var preview = Repository.Releases.GetPreview(promote); var deployment = Repository.Deployments.Create(new DeploymentResource { EnvironmentId = promote.Id, ReleaseId = release.Id, ForcePackageDownload = ForcePackageDownload, UseGuidedFailure = UseGuidedFailure.GetValueOrDefault(preview.UseGuidedFailureModeByDefault), SpecificMachineIds = specificMachineIds, ForcePackageRedeployment = ForcePackageRedeployment }); Log.InfoFormat("Deploying {0} {1} to: {2} (Guided Failure: {3})", project.Name, release.Version, environment.Name, deployment.UseGuidedFailure ? "Enabled" : "Not Enabled"); foreach (var previewStep in preview.StepsToExecute) { if (previewStep.HasNoApplicableMachines) { Log.Warn("Warning: there are no applicable machines roles used by step " + previewStep.ActionName + " step"); } } deployments.Add(deployment); deploymentTasks.Add(Repository.Tasks.Get(deployment.TaskId)); } if (WaitForDeployment) { WaitForDeploymentToComplete(deploymentTasks, deployments, project, release); } }
public ProjectGroupResource() { EnvironmentIds = new ReferenceCollection(); }
public void DeployRelease(ProjectResource project, ReleaseResource release, List<string> environments) { if (environments.Count == 0) return; var deployments = new List<DeploymentResource>(); var deploymentTasks = new List<TaskResource>(); var releaseTemplate = Repository.Releases.GetTemplate(release); var promotingEnvironments = (from environment in environments.Distinct(StringComparer.CurrentCultureIgnoreCase) let promote = releaseTemplate.PromoteTo.FirstOrDefault(p => string.Equals(p.Name, environment)) select new {Name = environment, Promote = promote}).ToList(); var unknownEnvironments = promotingEnvironments.Where(p => p.Promote == null).ToList(); if (unknownEnvironments.Count > 0) { throw new CommandException( string.Format("Release '{0}' of project '{1}' cannot be deployed to {2} not in the list of environments that this release can be deployed to. This may be because a) the environment does not exist, b) the name is misspelled, c) you don't have permission to deploy to this environment, or d) the environment is not in the list of environments defined by the lifecycle.", release.Version, project.Name, unknownEnvironments.Count == 1 ? "environment '" + unknownEnvironments[0].Name + "' because the environment is" : "environments " + string.Join(", ", unknownEnvironments.Select(e => "'" + e.Name + "'")) + " because the environments are" )); } var specificMachineIds = new ReferenceCollection(); if (SpecificMachineNames.Any()) { var machines = Repository.Machines.FindByNames(SpecificMachineNames); var missing = SpecificMachineNames.Except(machines.Select(m => m.Name), StringComparer.OrdinalIgnoreCase).ToList(); if (missing.Any()) { throw new CommandException("The following specific machines could not be found: " + missing.ReadableJoin()); } specificMachineIds.AddRange(machines.Select(m => m.Id)); } if (DeployAt != null) { var now = DateTimeOffset.UtcNow; Log.InfoFormat("Deployment will be scheduled to start in: {0}", (DeployAt.Value - now).FriendlyDuration()); } foreach (var environment in promotingEnvironments) { var promote = environment.Promote; var preview = Repository.Releases.GetPreview(promote); var skip = new ReferenceCollection(); foreach (var step in SkipStepNames) { var stepToExecute = preview.StepsToExecute.SingleOrDefault(s => string.Equals(s.ActionName, step, StringComparison.CurrentCultureIgnoreCase)); if (stepToExecute == null) { Log.WarnFormat("No step/action named '{0}' could be found when deploying to environment '{1}', so the step cannot be skipped.", step, environment); } else { Log.DebugFormat("Skipping step: {0}", stepToExecute.ActionName); skip.Add(stepToExecute.ActionId); } } if (preview.Form != null && preview.Form.Elements != null && preview.Form.Values != null) { foreach (var element in preview.Form.Elements) { var variableInput = element.Control as VariableValue; if (variableInput == null) { continue; } var value = variables.Get(variableInput.Label) ?? variables.Get(variableInput.Name); if (string.IsNullOrWhiteSpace(value) && element.IsValueRequired) { throw new ArgumentException("Please provide a variable for the prompted value " + variableInput.Label); } preview.Form.Values[element.Name] = value; } } var deployment = Repository.Deployments.Create(new DeploymentResource { EnvironmentId = promote.Id, SkipActions = skip, ReleaseId = release.Id, ForcePackageDownload = ForcePackageDownload, UseGuidedFailure = UseGuidedFailure.GetValueOrDefault(preview.UseGuidedFailureModeByDefault), SpecificMachineIds = specificMachineIds, ForcePackageRedeployment = ForcePackageRedeployment, FormValues = (preview.Form ?? new Form()).Values, QueueTime = DeployAt == null ? null : (DateTimeOffset?)DeployAt.Value }); Log.InfoFormat("Deploying {0} {1} to: {2} (Guided Failure: {3})", project.Name, release.Version, environment.Name, deployment.UseGuidedFailure ? "Enabled" : "Not Enabled"); foreach (var previewStep in preview.StepsToExecute) { if (previewStep.HasNoApplicableMachines) { Log.Warn("Warning: there are no applicable machines roles used by step " + previewStep.ActionName + " step"); } } deployments.Add(deployment); deploymentTasks.Add(Repository.Tasks.Get(deployment.TaskId)); } if (WaitForDeployment) { WaitForDeploymentToComplete(deploymentTasks, deployments, project, release); } }
public ProduireInvokeMemberBinder(string name, CallInfo callInfo, BinderFactory factory, ReferenceCollection reference) : base(name, callInfo, factory) { _reference = reference; }