本文整理汇总了C#中MgaFCOs.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# MgaFCOs.Cast方法的具体用法?C# MgaFCOs.Cast怎么用?C# MgaFCOs.Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MgaFCOs
的用法示例。
在下文中一共展示了MgaFCOs.Cast方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public void Main(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, ComponentStartMode startMode)
{
GMEConsole.Clear();
System.Windows.Forms.Application.DoEvents();
IMgaFCO selectedObj = null;
bool isContextValid = CheckForValidContext(currentobj);
if (isContextValid == false)
{
return;
}
// get all the ComponentRefs in the DesignContainer
var crefs = (currentobj as IMgaModel).
ChildFCOs.
Cast<IMgaFCO>().
Where(x => x.MetaBase.Name == "ComponentRef");
// If there is exactly '1', select it
if (crefs.Count() == 1)
{
selectedObj = crefs.FirstOrDefault();
}
if (selectedObj == null)
{
if (selectedobjs.Count != 1)
{
GMEConsole.Error.WriteLine(SelectedObjErrorMessage);
return;
}
selectedObj = selectedobjs.Cast<IMgaFCO>().FirstOrDefault();
}
if (selectedObj == null)
{
GMEConsole.Error.WriteLine(SelectedObjErrorMessage);
return;
}
if (selectedObj.MetaBase.Name != "ComponentRef")
{
GMEConsole.Error.WriteLine(SelectedObjErrorMessage);
return;
}
if ((selectedObj as IMgaReference).Referred == null)
{
GMEConsole.Error.WriteLine("Selected ComponentRef is a null reference.");
return;
}
GMEConsole.Info.WriteLine("Running CLM_light...");
// everything is checked we can operate on the objects
IMgaFCO designContainer = currentobj;
IMgaFCO componentRef = selectedObj;
IMgaModel component = (selectedObj as IMgaReference).Referred as IMgaModel;
GMEConsole.Info.WriteLine("Discovering components.");
//GMEConsole.Info.WriteLine("{0} components were found.", components.Count);
// TODO: filter detected components if needed
using (ComponentSelectionForm csf = new ComponentSelectionForm(component, currentobj as IMgaModel, GMEConsole.Error, GMEConsole.Info))
{
var dialogresult = csf.ShowDialog();
if (dialogresult == System.Windows.Forms.DialogResult.OK)
{
GMEConsole.Info.WriteLine("Inserting new components.");
List<IMgaFCO> components = new List<IMgaFCO>();
foreach (var item in csf.dgvSelector.SelectedRows)
{
var dgvr = item as System.Windows.Forms.DataGridViewRow;
var cli = dgvr.DataBoundItem as ComponentListItem;
components.Add(cli.Fco);
}
GMEConsole.Info.WriteLine("{0} components were selected.", components.Count);
List<KeyValuePair<IMgaFCO, string>> messages = new List<KeyValuePair<IMgaFCO, string>>();
var insertedComponents = InsertComponents(designContainer, componentRef, components, messages);
}
}
GMEConsole.Info.WriteLine("Done.");
}