Here are the examples of the csharp api System.Collections.Generic.List.Remove(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1095 Examples
19
Source : PostAppService.cs
with GNU Lesser General Public License v3.0
from cnAbp
with GNU Lesser General Public License v3.0
from cnAbp
private async Task RemoveOldTags(List<string> newTags, Post post)
{
foreach (var oldTag in post.Tags)
{
var tag = await _tagRepository.GetAsync(oldTag.TagId);
var oldTagNameInNewTags = newTags.FirstOrDefault(t => t == tag.Name);
if (oldTagNameInNewTags == null)
{
post.RemoveTag(oldTag.TagId);
tag.DecreaseUsageCount();
await _tagRepository.UpdateAsync(tag);
}
else
{
newTags.Remove(oldTagNameInNewTags);
}
}
}
19
Source : Program.cs
with GNU General Public License v3.0
from cobbr
with GNU General Public License v3.0
from cobbr
private static BridgeProfile GetProfile(ref string[] args)
{
BridgeProfile profile = new BridgeProfile();
if (args.Contains("--profile"))
{
List<string> argList = args.ToList();
int profIndex = argList.IndexOf("--profile");
if (args.Length < profIndex)
{
return null;
}
try
{
profile = BridgeProfile.Create(args[profIndex + 1]);
}
catch
{
return null;
}
argList.Remove(args[profIndex]);
argList.Remove(args[profIndex + 1]);
args = argList.ToArray();
}
return profile;
}
19
Source : Grunt.cs
with GNU General Public License v3.0
from cobbr
with GNU General Public License v3.0
from cobbr
public bool RemoveChild(Grunt grunt)
{
return this.Children.Remove(grunt.GUID);
}
19
Source : GruntsMenuItem.cs
with GNU General Public License v3.0
from cobbr
with GNU General Public License v3.0
from cobbr
public override void Command(MenuItem menuItem, string UserInput)
{
GruntsMenuItem gruntsMenuItem = (GruntsMenuItem)menuItem;
string[] commands = UserInput.Split(" ");
if (commands.Length != 2 || !commands[0].Equals("unhide", StringComparison.OrdinalIgnoreCase))
{
menuItem.PrintInvalidOptionError(UserInput);
return;
}
if (commands[1].Equals("all", StringComparison.OrdinalIgnoreCase))
{
gruntsMenuItem.HiddenGruntNames.Clear();
return;
}
string gruntName = gruntsMenuItem.HiddenGruntNames.FirstOrDefault(HGN => HGN == commands[1]);
if (string.IsNullOrEmpty(gruntName))
{
EliteConsole.PrintFormattedErrorLine("Invalid GruntName: \"" + commands[1] + "\"");
menuItem.PrintInvalidOptionError(UserInput);
return;
}
gruntsMenuItem.HiddenGruntNames.Remove(gruntName);
}
19
Source : BaseEditor.cs
with MIT License
from code51
with MIT License
from code51
protected GenericMenu BuildLoadMenu(string prefix, GenericMenu menu, Func<bool> callback)
{
List<string> categories = new List<string>();
menu.AddItem(new GUIContent(prefix + "Tree/Create New..."), false, delegate {
if (callback != null)
if (!callback())
return;
InitializeTree();
Repaint();
});
GetAllEntries().ForEach(entry => {
string name = entry.Replace("\\", "/").Replace(Application.dataPath + "/" + Settings.dialogues_path + "/", "").Replace(".json", "");
List<string> segments = name.Split('/').ToList();
segments.Remove(name.Split('/')[name.Split('/').Length - 1]);
string category = String.Join("/", segments.ToArray());
if (!categories.Contains(category)) {
menu.AddItem(new GUIContent(prefix + "Tree/" + category + "/Create New..."), false, delegate {
if (callback != null)
if (!callback())
return;
InitializeTree(category);
Repaint();
});
}
menu.AddItem(new GUIContent(prefix + "Tree/" + name), false, delegate {
if (callback != null)
if (!callback())
return;
LoadTree(entry);
});
});
return menu;
}
19
Source : EditModeRunner.cs
with MIT License
from CodeStarrk
with MIT License
from CodeStarrk
public void TestFinishedEvent(ITestResult testResult)
{
m_AlreadyStartedTests.Remove(testResult.FullName);
m_ExecutedTests.Add(TestResultSerializer.MakeFromTestResult(testResult));
}
19
Source : XLuaExportEditor.cs
with MIT License
from coding2233
with MIT License
from coding2233
void NamespaceDraw()
{
GUILayout.BeginVertical("helpbox", GUILayout.Width(Screen.width * 0.66f));
GUILayout.Label("Include Namespace", EditorStyles.boldLabel);
// GUILayout.BeginHorizontal();
// GUILayout.FlexibleSpace();
//if (GUILayout.Button("Apply", GUILayout.Width(100)))
//{
// XLuaExportSettings.SaveNamespaces(_selectNamespace);
//}
//GUILayout.EndHorizontal();
_nameSpaceScrollPos = GUILayout.BeginScrollView(_nameSpaceScrollPos, "helpbox");
foreach (var item in _allUnityNamespaces)
{
bool select = _selectNamespace.Contains(item);
bool result = GUILayout.Toggle(select, item);
if (select != result)
{
if (result)
{
_selectNamespace.Add(item);
}
else
{
_selectNamespace.Remove(item);
}
}
}
GUILayout.EndScrollView();
GUILayout.EndVertical();
}
19
Source : XLuaExportEditor.cs
with MIT License
from coding2233
with MIT License
from coding2233
void CustomreplacedemblyDraw()
{
GUILayout.BeginVertical("helpbox");
GUILayout.Label("Custom replacedembly", EditorStyles.boldLabel);
if (_customreplacedembly != null && _customreplacedembly.Count > 0)
{
//GUILayout.BeginHorizontal();
//GUILayout.FlexibleSpace();
//if (GUILayout.Button("Apply", GUILayout.Width(100)))
//{
// XLuaExportSettings.Savereplacedembly(_customreplacedembly);
//}
//GUILayout.EndHorizontal();
_customScrollPos = GUILayout.BeginScrollView(_customScrollPos, "helpbox");
foreach (var item in _allCustomreplacedembly)
{
bool select = _customreplacedembly.Contains(item);
bool result = GUILayout.Toggle(select, item);
if (select != result)
{
if (result)
{
_customreplacedembly.Add(item);
}
else
{
_customreplacedembly.Remove(item);
}
}
}
GUILayout.EndScrollView();
}
GUILayout.EndVertical();
}
19
Source : SkeletonBaker.cs
with MIT License
from coding2233
with MIT License
from coding2233
public static void BakeToPrefab (SkeletonDatareplacedet skeletonDatareplacedet, ExposedList<Skin> skins, string outputPath = "", bool bakeAnimations = true, bool bakeIK = true, SendMessageOptions eventOptions = SendMessageOptions.DontRequireReceiver) {
if (skeletonDatareplacedet == null || skeletonDatareplacedet.GetSkeletonData(true) == null) {
Debug.LogError("Could not export Spine Skeleton because SkeletonDatareplacedet is null or invalid!");
return;
}
if (outputPath == "") {
outputPath = System.IO.Path.GetDirectoryName(replacedetDatabase.GetreplacedetPath(skeletonDatareplacedet)).Replace('\\', '/') + "/Baked";
System.IO.Directory.CreateDirectory(outputPath);
}
var skeletonData = skeletonDatareplacedet.GetSkeletonData(true);
bool hasAnimations = bakeAnimations && skeletonData.Animations.Count > 0;
UnityEditor.Animations.AnimatorController controller = null;
if (hasAnimations) {
string controllerPath = outputPath + "/" + skeletonDatareplacedet.skeletonJSON.name + " Controller.controller";
bool newAnimContainer = false;
var runtimeController = replacedetDatabase.LoadreplacedetAtPath(controllerPath, typeof(RuntimeAnimatorController));
if (runtimeController != null) {
controller = (UnityEditor.Animations.AnimatorController)runtimeController;
} else {
controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath(controllerPath);
newAnimContainer = true;
}
var existingClipTable = new Dictionary<string, AnimationClip>();
var unusedClipNames = new List<string>();
Object[] animObjs = replacedetDatabase.LoadAllreplacedetsAtPath(controllerPath);
foreach (Object o in animObjs) {
if (o is AnimationClip) {
var clip = (AnimationClip)o;
existingClipTable.Add(clip.name, clip);
unusedClipNames.Add(clip.name);
}
}
Dictionary<int, List<string>> slotLookup = new Dictionary<int, List<string>>();
int skinCount = skins.Count;
for (int s = 0; s < skeletonData.Slots.Count; s++) {
List<string> attachmentNames = new List<string>();
for (int i = 0; i < skinCount; i++) {
var skin = skins.Items[i];
var skinEntries = new List<Skin.SkinEntry>();
skin.GetAttachments(s, skinEntries);
foreach (var entry in skinEntries) {
if (!attachmentNames.Contains(entry.Name))
attachmentNames.Add(entry.Name);
}
}
slotLookup.Add(s, attachmentNames);
}
foreach (var anim in skeletonData.Animations) {
AnimationClip clip = null;
if (existingClipTable.ContainsKey(anim.Name)) {
clip = existingClipTable[anim.Name];
}
clip = ExtractAnimation(anim.Name, skeletonData, slotLookup, bakeIK, eventOptions, clip);
if (unusedClipNames.Contains(clip.name)) {
unusedClipNames.Remove(clip.name);
} else {
replacedetDatabase.AddObjectToreplacedet(clip, controller);
controller.AddMotion(clip);
}
}
if (newAnimContainer) {
EditorUtility.SetDirty(controller);
replacedetDatabase.Savereplacedets();
replacedetDatabase.Importreplacedet(controllerPath, ImportreplacedetOptions.ForceUpdate);
replacedetDatabase.Refresh();
} else {
foreach (string str in unusedClipNames) {
AnimationClip.DestroyImmediate(existingClipTable[str], true);
}
EditorUtility.SetDirty(controller);
replacedetDatabase.Savereplacedets();
replacedetDatabase.Importreplacedet(controllerPath, ImportreplacedetOptions.ForceUpdate);
replacedetDatabase.Refresh();
}
}
foreach (var skin in skins) {
bool newPrefab = false;
string prefabPath = outputPath + "/" + skeletonDatareplacedet.skeletonJSON.name + " (" + skin.Name + ").prefab";
Object prefab = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject));
if (prefab == null) {
#if NEW_PREFAB_SYSTEM
GameObject emptyGameObject = new GameObject();
prefab = PrefabUtility.SaveAsPrefabreplacedetAndConnect(emptyGameObject, prefabPath, InteractionMode.AutomatedAction);
GameObject.DestroyImmediate(emptyGameObject);
#else
prefab = PrefabUtility.CreateEmptyPrefab(prefabPath);
#endif
newPrefab = true;
}
Dictionary<string, Mesh> meshTable = new Dictionary<string, Mesh>();
List<string> unusedMeshNames = new List<string>();
Object[] replacedets = replacedetDatabase.LoadAllreplacedetsAtPath(prefabPath);
foreach (var obj in replacedets) {
if (obj is Mesh) {
meshTable.Add(obj.name, (Mesh)obj);
unusedMeshNames.Add(obj.name);
}
}
GameObject prefabRoot = EditorInstantiation.NewGameObject("root", true);
Dictionary<string, Transform> slotTable = new Dictionary<string, Transform>();
Dictionary<string, Transform> boneTable = new Dictionary<string, Transform>();
List<Transform> boneList = new List<Transform>();
//create bones
for (int i = 0; i < skeletonData.Bones.Count; i++) {
var boneData = skeletonData.Bones.Items[i];
Transform boneTransform = EditorInstantiation.NewGameObject(boneData.Name, true).transform;
boneTransform.parent = prefabRoot.transform;
boneTable.Add(boneTransform.name, boneTransform);
boneList.Add(boneTransform);
}
for (int i = 0; i < skeletonData.Bones.Count; i++) {
var boneData = skeletonData.Bones.Items[i];
Transform boneTransform = boneTable[boneData.Name];
Transform parentTransform = null;
if (i > 0)
parentTransform = boneTable[boneData.Parent.Name];
else
parentTransform = boneTransform.parent;
boneTransform.parent = parentTransform;
boneTransform.localPosition = new Vector3(boneData.X, boneData.Y, 0);
var tm = boneData.TransformMode;
if (tm.InheritsRotation())
boneTransform.localRotation = Quaternion.Euler(0, 0, boneData.Rotation);
else
boneTransform.rotation = Quaternion.Euler(0, 0, boneData.Rotation);
if (tm.InheritsScale())
boneTransform.localScale = new Vector3(boneData.ScaleX, boneData.ScaleY, 1);
}
//create slots and attachments
for (int slotIndex = 0; slotIndex < skeletonData.Slots.Count; slotIndex++) {
var slotData = skeletonData.Slots.Items[slotIndex];
Transform slotTransform = EditorInstantiation.NewGameObject(slotData.Name, true).transform;
slotTransform.parent = prefabRoot.transform;
slotTable.Add(slotData.Name, slotTransform);
var skinEntries = new List<Skin.SkinEntry>();
skin.GetAttachments(slotIndex, skinEntries);
if (skin != skeletonData.DefaultSkin)
skeletonData.DefaultSkin.GetAttachments(slotIndex, skinEntries);
for (int a = 0; a < skinEntries.Count; a++) {
var attachment = skinEntries[a].Attachment;
string attachmentName = skinEntries[a].Name;
string attachmentMeshName = "[" + slotData.Name + "] " + attachmentName;
Vector3 offset = Vector3.zero;
float rotation = 0;
Mesh mesh = null;
Material material = null;
bool isWeightedMesh = false;
if (meshTable.ContainsKey(attachmentMeshName))
mesh = meshTable[attachmentMeshName];
if (attachment is RegionAttachment) {
var regionAttachment = (RegionAttachment)attachment;
offset.x = regionAttachment.X;
offset.y = regionAttachment.Y;
rotation = regionAttachment.Rotation;
mesh = ExtractRegionAttachment(attachmentMeshName, regionAttachment, mesh);
material = attachment.GetMaterial();
unusedMeshNames.Remove(attachmentMeshName);
if (newPrefab || meshTable.ContainsKey(attachmentMeshName) == false)
replacedetDatabase.AddObjectToreplacedet(mesh, prefab);
} else if (attachment is MeshAttachment) {
var meshAttachment = (MeshAttachment)attachment;
isWeightedMesh = (meshAttachment.Bones != null);
offset.x = 0;
offset.y = 0;
rotation = 0;
if (isWeightedMesh)
mesh = ExtractWeightedMeshAttachment(attachmentMeshName, meshAttachment, slotIndex, skeletonData, boneList, mesh);
else
mesh = ExtractMeshAttachment(attachmentMeshName, meshAttachment, mesh);
material = attachment.GetMaterial();
unusedMeshNames.Remove(attachmentMeshName);
if (newPrefab || meshTable.ContainsKey(attachmentMeshName) == false)
replacedetDatabase.AddObjectToreplacedet(mesh, prefab);
} else
continue;
Transform attachmentTransform = EditorInstantiation.NewGameObject(attachmentName, true).transform;
attachmentTransform.parent = slotTransform;
attachmentTransform.localPosition = offset;
attachmentTransform.localRotation = Quaternion.Euler(0, 0, rotation);
if (isWeightedMesh) {
attachmentTransform.position = Vector3.zero;
attachmentTransform.rotation = Quaternion.idenreplacedy;
var skinnedMeshRenderer = attachmentTransform.gameObject.AddComponent<SkinnedMeshRenderer>();
skinnedMeshRenderer.rootBone = boneList[0];
skinnedMeshRenderer.bones = boneList.ToArray();
skinnedMeshRenderer.sharedMesh = mesh;
} else {
attachmentTransform.gameObject.AddComponent<MeshFilter>().sharedMesh = mesh;
attachmentTransform.gameObject.AddComponent<MeshRenderer>();
}
attachmentTransform.GetComponent<Renderer>().sharedMaterial = material;
attachmentTransform.GetComponent<Renderer>().sortingOrder = slotIndex;
if (attachmentName != slotData.AttachmentName)
attachmentTransform.gameObject.SetActive(false);
}
}
foreach (var slotData in skeletonData.Slots) {
Transform slotTransform = slotTable[slotData.Name];
slotTransform.parent = boneTable[slotData.BoneData.Name];
slotTransform.localPosition = Vector3.zero;
slotTransform.localRotation = Quaternion.idenreplacedy;
slotTransform.localScale = Vector3.one;
}
if (hasAnimations) {
var animator = prefabRoot.AddComponent<Animator>();
animator.applyRootMotion = false;
animator.runtimeAnimatorController = (RuntimeAnimatorController)controller;
EditorGUIUtility.PingObject(controller);
}
if (newPrefab) {
#if NEW_PREFAB_SYSTEM
PrefabUtility.SaveAsPrefabreplacedetAndConnect(prefabRoot, prefabPath, InteractionMode.AutomatedAction);
#else
PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ConnectToPrefab);
#endif
} else {
foreach (string str in unusedMeshNames) {
Mesh.DestroyImmediate(meshTable[str], true);
}
#if NEW_PREFAB_SYSTEM
PrefabUtility.SaveAsPrefabreplacedetAndConnect(prefabRoot, prefabPath, InteractionMode.AutomatedAction);
#else
PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ReplaceNameBased);
#endif
}
EditorGUIUtility.PingObject(prefab);
replacedetDatabase.Refresh();
replacedetDatabase.Savereplacedets();
GameObject.DestroyImmediate(prefabRoot);
}
}
19
Source : CreatingGameTemplateEditor.cs
with MIT License
from coding2233
with MIT License
from coding2233
void ShowGameList()
{
scrollPos = GUILayout.BeginScrollView(scrollPos, "helpbox", GUILayout.Height(Screen.height * 0.45f));
if (gameFolderList != null && gameFolderList.Count > 0)
{
foreach (var item in gameFolderList)
{
bool select = deleteList.Contains(item);
bool result = GUILayout.Toggle(select, item);
if (select != result)
{
if (result)
{
deleteList.Add(item);
}
else
{
deleteList.Remove(item);
}
}
}
}
GUILayout.EndScrollView();
}
19
Source : SkeletonBaker.cs
with MIT License
from coding2233
with MIT License
from coding2233
public static void BakeToPrefab (SkeletonDatareplacedet skeletonDatareplacedet, ExposedList<Skin> skins, string outputPath = "", bool bakeAnimations = true, bool bakeIK = true, SendMessageOptions eventOptions = SendMessageOptions.DontRequireReceiver) {
if (skeletonDatareplacedet == null || skeletonDatareplacedet.GetSkeletonData(true) == null) {
Debug.LogError("Could not export Spine Skeleton because SkeletonDatareplacedet is null or invalid!");
return;
}
if (outputPath == "") {
outputPath = System.IO.Path.GetDirectoryName(replacedetDatabase.GetreplacedetPath(skeletonDatareplacedet)).Replace('\\', '/') + "/Baked";
System.IO.Directory.CreateDirectory(outputPath);
}
var skeletonData = skeletonDatareplacedet.GetSkeletonData(true);
bool hasAnimations = bakeAnimations && skeletonData.Animations.Count > 0;
UnityEditor.Animations.AnimatorController controller = null;
if (hasAnimations) {
string controllerPath = outputPath + "/" + skeletonDatareplacedet.skeletonJSON.name + " Controller.controller";
bool newAnimContainer = false;
var runtimeController = replacedetDatabase.LoadreplacedetAtPath(controllerPath, typeof(RuntimeAnimatorController));
if (runtimeController != null) {
controller = (UnityEditor.Animations.AnimatorController)runtimeController;
} else {
controller = UnityEditor.Animations.AnimatorController.CreateAnimatorControllerAtPath(controllerPath);
newAnimContainer = true;
}
var existingClipTable = new Dictionary<string, AnimationClip>();
var unusedClipNames = new List<string>();
Object[] animObjs = replacedetDatabase.LoadAllreplacedetsAtPath(controllerPath);
foreach (Object o in animObjs) {
if (o is AnimationClip) {
var clip = (AnimationClip)o;
existingClipTable.Add(clip.name, clip);
unusedClipNames.Add(clip.name);
}
}
Dictionary<int, List<string>> slotLookup = new Dictionary<int, List<string>>();
int skinCount = skins.Count;
for (int s = 0; s < skeletonData.Slots.Count; s++) {
List<string> attachmentNames = new List<string>();
for (int i = 0; i < skinCount; i++) {
var skin = skins.Items[i];
var skinEntries = new List<Skin.SkinEntry>();
skin.GetAttachments(s, skinEntries);
foreach (var entry in skinEntries) {
if (!attachmentNames.Contains(entry.Name))
attachmentNames.Add(entry.Name);
}
}
slotLookup.Add(s, attachmentNames);
}
foreach (var anim in skeletonData.Animations) {
AnimationClip clip = null;
if (existingClipTable.ContainsKey(anim.Name)) {
clip = existingClipTable[anim.Name];
}
clip = ExtractAnimation(anim.Name, skeletonData, slotLookup, bakeIK, eventOptions, clip);
if (unusedClipNames.Contains(clip.name)) {
unusedClipNames.Remove(clip.name);
} else {
replacedetDatabase.AddObjectToreplacedet(clip, controller);
controller.AddMotion(clip);
}
}
if (newAnimContainer) {
EditorUtility.SetDirty(controller);
replacedetDatabase.Savereplacedets();
replacedetDatabase.Importreplacedet(controllerPath, ImportreplacedetOptions.ForceUpdate);
replacedetDatabase.Refresh();
} else {
foreach (string str in unusedClipNames) {
AnimationClip.DestroyImmediate(existingClipTable[str], true);
}
EditorUtility.SetDirty(controller);
replacedetDatabase.Savereplacedets();
replacedetDatabase.Importreplacedet(controllerPath, ImportreplacedetOptions.ForceUpdate);
replacedetDatabase.Refresh();
}
}
foreach (var skin in skins) {
bool newPrefab = false;
string prefabPath = outputPath + "/" + skeletonDatareplacedet.skeletonJSON.name + " (" + skin.Name + ").prefab";
Object prefab = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject));
if (prefab == null) {
#if NEW_PREFAB_SYSTEM
GameObject emptyGameObject = new GameObject();
prefab = PrefabUtility.SaveAsPrefabreplacedetAndConnect(emptyGameObject, prefabPath, InteractionMode.AutomatedAction);
GameObject.DestroyImmediate(emptyGameObject);
#else
prefab = PrefabUtility.CreateEmptyPrefab(prefabPath);
#endif
newPrefab = true;
}
Dictionary<string, Mesh> meshTable = new Dictionary<string, Mesh>();
List<string> unusedMeshNames = new List<string>();
Object[] replacedets = replacedetDatabase.LoadAllreplacedetsAtPath(prefabPath);
foreach (var obj in replacedets) {
if (obj is Mesh) {
meshTable.Add(obj.name, (Mesh)obj);
unusedMeshNames.Add(obj.name);
}
}
GameObject prefabRoot = EditorInstantiation.NewGameObject("root", true);
Dictionary<string, Transform> slotTable = new Dictionary<string, Transform>();
Dictionary<string, Transform> boneTable = new Dictionary<string, Transform>();
List<Transform> boneList = new List<Transform>();
//create bones
for (int i = 0; i < skeletonData.Bones.Count; i++) {
var boneData = skeletonData.Bones.Items[i];
Transform boneTransform = EditorInstantiation.NewGameObject(boneData.Name, true).transform;
boneTransform.parent = prefabRoot.transform;
boneTable.Add(boneTransform.name, boneTransform);
boneList.Add(boneTransform);
}
for (int i = 0; i < skeletonData.Bones.Count; i++) {
var boneData = skeletonData.Bones.Items[i];
Transform boneTransform = boneTable[boneData.Name];
Transform parentTransform = null;
if (i > 0)
parentTransform = boneTable[boneData.Parent.Name];
else
parentTransform = boneTransform.parent;
boneTransform.parent = parentTransform;
boneTransform.localPosition = new Vector3(boneData.X, boneData.Y, 0);
var tm = boneData.TransformMode;
if (tm.InheritsRotation())
boneTransform.localRotation = Quaternion.Euler(0, 0, boneData.Rotation);
else
boneTransform.rotation = Quaternion.Euler(0, 0, boneData.Rotation);
if (tm.InheritsScale())
boneTransform.localScale = new Vector3(boneData.ScaleX, boneData.ScaleY, 1);
}
//create slots and attachments
for (int slotIndex = 0; slotIndex < skeletonData.Slots.Count; slotIndex++) {
var slotData = skeletonData.Slots.Items[slotIndex];
Transform slotTransform = EditorInstantiation.NewGameObject(slotData.Name, true).transform;
slotTransform.parent = prefabRoot.transform;
slotTable.Add(slotData.Name, slotTransform);
var skinEntries = new List<Skin.SkinEntry>();
skin.GetAttachments(slotIndex, skinEntries);
if (skin != skeletonData.DefaultSkin)
skeletonData.DefaultSkin.GetAttachments(slotIndex, skinEntries);
for (int a = 0; a < skinEntries.Count; a++) {
var attachment = skinEntries[a].Attachment;
string attachmentName = skinEntries[a].Name;
string attachmentMeshName = "[" + slotData.Name + "] " + attachmentName;
Vector3 offset = Vector3.zero;
float rotation = 0;
Mesh mesh = null;
Material material = null;
bool isWeightedMesh = false;
if (meshTable.ContainsKey(attachmentMeshName))
mesh = meshTable[attachmentMeshName];
if (attachment is RegionAttachment) {
var regionAttachment = (RegionAttachment)attachment;
offset.x = regionAttachment.X;
offset.y = regionAttachment.Y;
rotation = regionAttachment.Rotation;
mesh = ExtractRegionAttachment(attachmentMeshName, regionAttachment, mesh);
material = attachment.GetMaterial();
unusedMeshNames.Remove(attachmentMeshName);
if (newPrefab || meshTable.ContainsKey(attachmentMeshName) == false)
replacedetDatabase.AddObjectToreplacedet(mesh, prefab);
} else if (attachment is MeshAttachment) {
var meshAttachment = (MeshAttachment)attachment;
isWeightedMesh = (meshAttachment.Bones != null);
offset.x = 0;
offset.y = 0;
rotation = 0;
if (isWeightedMesh)
mesh = ExtractWeightedMeshAttachment(attachmentMeshName, meshAttachment, slotIndex, skeletonData, boneList, mesh);
else
mesh = ExtractMeshAttachment(attachmentMeshName, meshAttachment, mesh);
material = attachment.GetMaterial();
unusedMeshNames.Remove(attachmentMeshName);
if (newPrefab || meshTable.ContainsKey(attachmentMeshName) == false)
replacedetDatabase.AddObjectToreplacedet(mesh, prefab);
} else
continue;
Transform attachmentTransform = EditorInstantiation.NewGameObject(attachmentName, true).transform;
attachmentTransform.parent = slotTransform;
attachmentTransform.localPosition = offset;
attachmentTransform.localRotation = Quaternion.Euler(0, 0, rotation);
if (isWeightedMesh) {
attachmentTransform.position = Vector3.zero;
attachmentTransform.rotation = Quaternion.idenreplacedy;
var skinnedMeshRenderer = attachmentTransform.gameObject.AddComponent<SkinnedMeshRenderer>();
skinnedMeshRenderer.rootBone = boneList[0];
skinnedMeshRenderer.bones = boneList.ToArray();
skinnedMeshRenderer.sharedMesh = mesh;
} else {
attachmentTransform.gameObject.AddComponent<MeshFilter>().sharedMesh = mesh;
attachmentTransform.gameObject.AddComponent<MeshRenderer>();
}
attachmentTransform.GetComponent<Renderer>().sharedMaterial = material;
attachmentTransform.GetComponent<Renderer>().sortingOrder = slotIndex;
if (attachmentName != slotData.AttachmentName)
attachmentTransform.gameObject.SetActive(false);
}
}
foreach (var slotData in skeletonData.Slots) {
Transform slotTransform = slotTable[slotData.Name];
slotTransform.parent = boneTable[slotData.BoneData.Name];
slotTransform.localPosition = Vector3.zero;
slotTransform.localRotation = Quaternion.idenreplacedy;
slotTransform.localScale = Vector3.one;
}
if (hasAnimations) {
var animator = prefabRoot.AddComponent<Animator>();
animator.applyRootMotion = false;
animator.runtimeAnimatorController = (RuntimeAnimatorController)controller;
EditorGUIUtility.PingObject(controller);
}
if (newPrefab) {
#if NEW_PREFAB_SYSTEM
PrefabUtility.SaveAsPrefabreplacedetAndConnect(prefabRoot, prefabPath, InteractionMode.AutomatedAction);
#else
PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ConnectToPrefab);
#endif
} else {
foreach (string str in unusedMeshNames) {
Mesh.DestroyImmediate(meshTable[str], true);
}
#if NEW_PREFAB_SYSTEM
PrefabUtility.SaveAsPrefabreplacedetAndConnect(prefabRoot, prefabPath, InteractionMode.AutomatedAction);
#else
PrefabUtility.ReplacePrefab(prefabRoot, prefab, ReplacePrefabOptions.ReplaceNameBased);
#endif
}
EditorGUIUtility.PingObject(prefab);
replacedetDatabase.Refresh();
replacedetDatabase.Savereplacedets();
GameObject.DestroyImmediate(prefabRoot);
}
}
19
Source : CoinigyWsClient.cs
with GNU General Public License v3.0
from Coinigy
with GNU General Public License v3.0
from Coinigy
public IEnumerable<string> GetChannels()
{
if (_scClient == null || _scClient.SocketState != WebSocketState.Open)
return null;
var results = new List<string>();
var ackReceived = false;
_scClient.Emit("channels", "", (name, error, data) =>
{
var res = (List<dynamic>)data;
foreach (Dictionary<string, object> r in res)
{
try
{
results.Add(r.Values.First().ToString());
}
catch
{
// ignore stupid items
}
}
ackReceived = true;
});
var st = DateTime.UtcNow;
do
{
// just wait a few for results if needed
if (ackReceived)
break;
} while (st.AddSeconds(20000) > DateTime.UtcNow);
// remove depreciated
if (results.Contains("TICKER"))
results.Remove("TICKER");
if (results.Contains("CHATMSG"))
results.Remove("CHATMSG");
if (results.Contains("NOTIFICATION"))
results.Remove("NOTIFICATION");
return results;
}
19
Source : WcfMSBase.cs
with Apache License 2.0
from Coldairarrow
with Apache License 2.0
from Coldairarrow
protected void RemoveServiceUrl(string serviceName, string serviceUrl)
{
string cacheKey = BuildCacheKey(serviceName);
List<string> serviceUrls = GetServiceUrls(serviceName);
if (serviceUrls != null)
{
serviceUrls.Remove(serviceUrl);
_redisCache.SetCache(cacheKey, serviceUrls);
}
}
19
Source : CommentProvider.cs
with GNU General Public License v3.0
from CommentViewerCollection
with GNU General Public License v3.0
from CommentViewerCollection
private void BlackListProvider_Received(object sender, List<string> e)
{
try
{
var blackList = e;
//現状BAN状態のユーザ
var banned = _userDict.Where(kv => kv.Value.IsSiteNgUser).Select(kv => kv.Key).ToList();// _userViewModelDict.Where(kv => kv.Value.IsNgUser).Select(kv => kv.Key).ToList();
//ブラックリストに登録されているユーザのBANフラグをONにする
foreach (var black in blackList)
{
if (_userDict.ContainsKey(black))
{
var user = _userDict[black];
user.IsSiteNgUser = true;
}
//ブラックリストに入っていることが確認できたためリストから外す
banned.Remove(black);
}
//ブラックリストに入っていなかったユーザのBANフラグをOFFにする
foreach (var white in banned)
{
var u = _userDict[white];
u.IsSiteNgUser = false;
}
}
catch (Exception ex)
{
_logger.LogException(ex);
}
}
19
Source : frmLeaveCreate.cs
with MIT License
from comsmobiler
with MIT License
from comsmobiler
private void btnDelCheckClick(object sender, EventArgs e)
{
try
{
object checkUser = ((MobileControl)sender).Tag;//获取财务审批人头像
if (checkUser != null)
{
listCheckUsers.Remove(checkUser.ToString());//删除财务审批人
foreach (Panel plCheckMan in listplCheckUsersP)
{
if (plCheckMan.Name.Equals("plCheckMan" + checkUser))
{
listplCheckUsersP.Remove(plCheckMan);//删除财务审批头像控件
pCheck2.Controls.Remove((MobileControl)plCheckMan);//删除界面中财务审批头像控件
break;
}
}
//checkTop = lblCheck.Top + lblCheck.Height;
CheckusersSort();//审批人相关控件排序
checkUser = null;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
19
Source : frmBoCreate.cs
with MIT License
from comsmobiler
with MIT License
from comsmobiler
public void Removereplaced(string replacedId)
{
try
{
DataRow row = replacedTable.Rows.Find(replacedId);
replacedTable.Rows.Remove(row);
replacedIdList.Remove(replacedId);
}
catch (Exception ex)
{
Toast(ex.Message);
}
}
19
Source : frmCostTempletCreate.cs
with MIT License
from comsmobiler
with MIT License
from comsmobiler
private void btnDelCheckClick(object sender, EventArgs e)
{
try
{
object AEACheck = ((MobileControl)sender).Tag;//��ȡ����������ͷ��
if (AEACheck != null)
{
listAEAChecks.Remove(AEACheck.ToString());//ɾ������������
foreach (Smobiler.Core.Controls.ImageButton imgbtnAEACheck in listbtnAEAChecksP)
{
if (imgbtnAEACheck.Name.Equals("imgbtnAEACheck" + AEACheck))
{
listbtnAEAChecksP.Remove(imgbtnAEACheck);//ɾ����������ͷ��ؼ�
this.panel1.Controls.Remove((MobileControl)imgbtnAEACheck);//ɾ����������������ͷ��ؼ�
break;
}
}
foreach (Button btnAEACheck in listbtnAEAChecks)
{
if (btnAEACheck.Name.Equals("btnAEACheck" + AEACheck))
{
listbtnAEAChecks.Remove(btnAEACheck);//ɾ�������������ƿؼ�
this.panel1 . Controls.Remove((MobileControl)btnAEACheck);//ɾ�������������������ƿؼ�
break;
}
}
AEACheckTop = lblAEACheckers.Top + lblAEACheckers.Height;
AEAChecksSort();//����������ؿؼ�����
AEACheck = null;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
19
Source : frmCostTempletCreate.cs
with MIT License
from comsmobiler
with MIT License
from comsmobiler
private void btnDelFCheckClick(object sender, EventArgs e)
{
try
{
object FCheck = ((MobileControl)sender).Tag;//��ȡ����������ͷ��
if (FCheck != null)
{
listFCheckers.Remove(FCheck.ToString());//ɾ������������
foreach (Smobiler.Core.Controls.ImageButton imgbtnFChecker in listbtnFCheckersP)
{
if (imgbtnFChecker.Name.Equals("imgbtnFCheck" + FCheck))
{
listbtnFCheckersP.Remove(imgbtnFChecker);//ɾ����������ͷ��ؼ�
this.panel1.Controls.Remove((MobileControl)imgbtnFChecker);//ɾ�������в�������ͷ��ؼ�
break;
}
}
foreach (Button btnFChecker in listbtnFCheckers)
{
if (btnFChecker.Name.Equals("btnFCheck" + FCheck))
{
listbtnFCheckers.Remove(btnFChecker);//ɾ�������������ƿؼ�
this.panel1.Controls.Remove((MobileControl)btnFChecker);//ɾ�������в����������ƿؼ�
break;
}
}
AEACheckTop = lblAEACheckers.Top + lblAEACheckers.Height;
AEAChecksSort();//����������ؿؼ�����
FCheck = null;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
19
Source : frmLeaveCreate.cs
with MIT License
from comsmobiler
with MIT License
from comsmobiler
private void btnDelCCToClick(object sender, EventArgs e)
{
try
{
object CCUser = ((MobileControl)sender).Tag;//获取抄送人头像
if (CCUser != null)
{
listCCToUsers.Remove(CCUser.ToString());//删除抄送人
foreach (Panel plCCToMan in listplCCToUsersP)
{
if (plCCToMan.Name.Equals("plCCToMan" + CCUser))
{
listplCCToUsersP.Remove(plCCToMan);//删除抄送人头像控件
pCCTo2.Controls.Remove((MobileControl)plCCToMan);//删除界面中抄送人头像控件
break;
}
}
CCToUsersSort();//抄送人相关控件排序
CCUser = null;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
19
Source : frmConsumablesChoose.cs
with MIT License
from comsmobiler
with MIT License
from comsmobiler
public void RemoveCon(string CId)
{
try
{
DataRow row = ConTable.Rows.Find(CId);
ConTable.Rows.Remove(row);
ConList.Remove(CId);
}
catch (Exception ex)
{
Toast(ex.Message);
}
}
19
Source : frmOutOrderCreate.cs
with MIT License
from comsmobiler
with MIT License
from comsmobiler
public void RemoveCon(string CID)
{
try
{
DataRow row=ConTable.Rows.Find(CID);
ConTable.Rows.Remove(row);
ConList.Remove(CID);
}
catch (Exception ex)
{
Toast(ex.Message);
}
}
19
Source : frmAssIn.cs
with MIT License
from comsmobiler
with MIT License
from comsmobiler
public void RemoveSN(string SN)
{
DataRow row = SNTable.Rows.Find(SN);
if (row != null)
{
SNTable.Rows.Remove(row);
snList.Remove(SN);
lvSN.DataSource = SNTable;
lvSN.DataBind();
lblQuant.Text = "ʣ��: " + GetRest();
}
}
19
Source : frmWRCreate.cs
with MIT License
from comsmobiler
with MIT License
from comsmobiler
public void RemoveCon(string CID)
{
try
{
DataRow row = ConTable.Rows.Find(CID);
ConTable.Rows.Remove(row);
ConList.Remove(CID);
}
catch (Exception ex)
{
Toast(ex.Message);
}
}
19
Source : frmAssOut.cs
with MIT License
from comsmobiler
with MIT License
from comsmobiler
public void RemoveSN(string SN)
{
DataRow row = SNTable.Rows.Find(SN);
if (row != null)
{
SNTable.Rows.Remove(row);
snList.Remove(SN);
lvSN.DataSource = SNTable;
lvSN.DataBind();
}
}
19
Source : MainWindow.cs
with GNU General Public License v3.0
from CoretechR
with GNU General Public License v3.0
from CoretechR
private void RemoveBox_Click(object sender, EventArgs e)
{
if(listBox1.SelectedItem != null)
Layouts[currentLayout].Apps.Remove(listBox1.SelectedItem.ToString());
listBox1.DataSource = null;
listBox1.DataSource = Layouts[currentLayout].Apps;
}
19
Source : ReferenceList.cs
with MIT License
from CoreWCF
with MIT License
from CoreWCF
public bool TryRemoveReferredId(string id)
{
if (id == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException(nameof(id)));
}
return _referredIds.Remove(id);
}
19
Source : SceneSwitcherWindow.cs
with MIT License
from coryleach
with MIT License
from coryleach
private void SceneListGui()
{
_scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);
GUILayout.BeginVertical(new GUIStyle("GroupBox"));
foreach (var guid in _sceneSwitcherData.sceneGuids)
{
GUILayout.BeginHorizontal();
if (_editing)
{
if (GUILayout.Button("↑", GUILayout.MaxWidth(20)))
{
MoveUp(guid);
return;
}
if (GUILayout.Button("↓", GUILayout.MaxWidth(20)))
{
MoveDown(guid);
return;
}
}
var path = replacedetDatabase.GUIDToreplacedetPath(guid);
if (GUILayout.Button(System.IO.Path.GetFileNameWithoutExtension(path)))
{
// Give user option to save/cancel
if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
{
return;
}
SwitchToScene(path);
if (_sceneSwitcherData.sortRecentToTop)
{
MoveToTop(guid);
}
return;
}
if (_editing)
{
GUI.backgroundColor = Color.red;
if (GUILayout.Button("X", GUILayout.MaxWidth(20)))
{
_sceneSwitcherData.sceneGuids.Remove(guid);
return;
}
GUI.backgroundColor = Color.white;
}
GUILayout.EndHorizontal();
}
GUILayout.EndVertical();
const int lineHeight = 18;
if (_editing)
{
//Draw Toggle Buttons
GUILayout.BeginHorizontal();
_sceneSwitcherData.sortRecentToTop = GUILayout.Toggle(_sceneSwitcherData.sortRecentToTop,
new GUIContent("Auto Sort", "Will sort most recently used scenes to the top"),
GUILayout.Height(lineHeight));
_sceneSwitcherData.loadAdditive = GUILayout.Toggle(_sceneSwitcherData.loadAdditive,
new GUIContent("Additive", "Loads scenes additively"), GUILayout.Height(lineHeight));
_sceneSwitcherData.closeScenes = GUILayout.Toggle(_sceneSwitcherData.closeScenes,
new GUIContent("Close", "Will close/unload other scenes when additive loading is active"),
GUILayout.Height(lineHeight));
GUILayout.EndHorizontal();
//Draw Done Button
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUI.backgroundColor = Color.green;
if (GUILayout.Button("Done", GUILayout.MaxWidth(60)))
{
_editing = !_editing;
}
GUI.backgroundColor = Color.white;
GUILayout.EndHorizontal();
}
EditorGUILayout.EndScrollView();
}
19
Source : SceneSwitcherWindow.cs
with MIT License
from coryleach
with MIT License
from coryleach
private void MoveToTop(string guid)
{
_sceneSwitcherData.sceneGuids.Remove(guid);
_sceneSwitcherData.sceneGuids.Insert(0, guid);
}
19
Source : InstrumenterHelper.Assertions.cs
with MIT License
from coverlet-coverage
with MIT License
from coverlet-coverage
public static Doreplacedent replacedertBranchesCovered(this Doreplacedent doreplacedent, BuildConfiguration configuration, params (int line, int ordinal, int hits)[] lines)
{
if (doreplacedent is null)
{
throw new ArgumentNullException(nameof(doreplacedent));
}
BuildConfiguration buildConfiguration = GetreplacedemblyBuildConfiguration();
if ((buildConfiguration & configuration) != buildConfiguration)
{
return doreplacedent;
}
List<string> branchesToCover = new List<string>(lines.Select(b => $"[line {b.line} ordinal {b.ordinal}]"));
foreach (KeyValuePair<BranchKey, Branch> branch in doreplacedent.Branches)
{
foreach ((int lineToCheck, int ordinalToCheck, int expectedHits) in lines)
{
if (branch.Value.Number == lineToCheck)
{
if (branch.Value.Ordinal == ordinalToCheck)
{
branchesToCover.Remove($"[line {branch.Value.Number} ordinal {branch.Value.Ordinal}]");
if (branch.Value.Hits != expectedHits)
{
throw new XunitException($"Unexpected hits expected line: {lineToCheck} ordinal {ordinalToCheck} hits: {expectedHits} actual hits: {branch.Value.Hits}");
}
}
}
}
}
if (branchesToCover.Count != 0)
{
throw new XunitException($"Not all requested branch found, {branchesToCover.Select(l => l.ToString()).Aggregate((a, b) => $"{a}, {b}")}");
}
return doreplacedent;
}
19
Source : Sys_UserService.cs
with MIT License
from cq-panda
with MIT License
from cq-panda
public override WebResponseContent Export(PageDataOptions pageData)
{
//限定只能导出当前角色能看到的所有用户
QueryRelativeExpression = (IQueryable<Sys_User> queryable) =>
{
if (UserContext.Current.IsSuperAdmin) return queryable;
List<int> roleIds = Sys_RoleService
.Instance
.GetAllChildrenRoleId(UserContext.Current.RoleId);
return queryable.Where(x => roleIds.Contains(x.Role_Id) || x.User_Id == UserContext.Current.UserId);
};
base.ExportOnExecuting = (List<Sys_User> list, List<string> ignoreColumn) =>
{
if (!ignoreColumn.Contains("Role_Id"))
{
ignoreColumn.Add("Role_Id");
}
if (!ignoreColumn.Contains("RoleName"))
{
ignoreColumn.Remove("RoleName");
}
WebResponseContent responseData = new WebResponseContent(true);
return responseData;
};
return base.Export(pageData);
}
19
Source : SteamDirParsingUtils.cs
with MIT License
from cr4yz
with MIT License
from cr4yz
public static void RemoveSteamLibrary(string path)
{
string libraryVdfPath = Path.Combine(SteamDirectory, @"steamapps\libraryfolders.vdf");
if (File.Exists(libraryVdfPath))
{
var lines = File.ReadAllLines(libraryVdfPath).ToList();
string searchString = string.Format("\"{0}\"", path).Replace(@"\", @"\\");
foreach (string line in lines.ToArray())
{
if (line.TrimEnd().EndsWith(searchString, StringComparison.OrdinalIgnoreCase))
lines.Remove(line);
}
File.WriteAllLines(libraryVdfPath, lines);
}
}
19
Source : PropSpawner.cs
with MIT License
from cr4yz
with MIT License
from cr4yz
private void AddTag(string tag)
{
var clone = GameObject.Instantiate(_tagButtonTemplate, _tagButtonTemplate.transform.parent);
clone.gameObject.SetActive(true);
clone.Initialize(tag);
_tagButtons.Add(clone);
clone.OnEnabled.AddListener(() =>
{
_selectedTags.Add(tag);
UpdatePropList();
});
clone.OnDisabled.AddListener(() =>
{
_selectedTags.Remove(tag);
UpdatePropList();
});
}
19
Source : TriggerZonePlaceObjsWithin.cs
with MIT License
from cre8ivepark
with MIT License
from cre8ivepark
void OnTriggerExit(Collider other)
{
if (currCollidingObjs.Contains(other.gameObject.name))
{
justTriggered = true;
currCollidingObjs.Remove(other.gameObject.name);
CheckForCompletion();
}
}
19
Source : XRSDKConfigurationChecker.cs
with MIT License
from cre8ivepark
with MIT License
from cre8ivepark
private static void UpdateAsmDef()
{
FileInfo[] asmDefFiles = FileUtilities.FindFilesInreplacedets(AsmDefFileName);
if (asmDefFiles.Length == 0)
{
Debug.LogWarning($"Unable to locate file: {AsmDefFileName}");
return;
}
if (asmDefFiles.Length > 1)
{
Debug.LogWarning($"Multiple ({asmDefFiles.Length}) {AsmDefFileName} instances found. Modifying only the first.");
}
replacedemblyDefinition asmDef = replacedemblyDefinition.Load(asmDefFiles[0].FullName);
if (asmDef == null)
{
Debug.LogWarning($"Unable to load file: {AsmDefFileName}");
return;
}
List<string> references = new List<string>();
if (asmDef.References != null)
{
references.AddRange(asmDef.References);
}
bool changed = false;
#if UNITY_2019_3_OR_NEWER
List<VersionDefine> versionDefines = new List<VersionDefine>();
if (asmDef.VersionDefines != null)
{
versionDefines.AddRange(asmDef.VersionDefines);
}
if (!references.Contains(XRManagementReference))
{
// Add a reference to the ARFoundation replacedembly
references.Add(XRManagementReference);
changed = true;
}
if (!references.Contains(ARSubsystemsReference))
{
// Add a reference to the ARSubsystems replacedembly
references.Add(ARSubsystemsReference);
changed = true;
}
if (!references.Contains(SpatialTrackingReference))
{
// Add a reference to the spatial tracking replacedembly
references.Add(SpatialTrackingReference);
changed = true;
}
if (!versionDefines.Contains(XRManagementDefine))
{
// Add the XRManagement #define
versionDefines.Add(XRManagementDefine);
changed = true;
}
if (!versionDefines.Contains(ARSubsystemsDefine))
{
// Add the ARSubsystems #define
versionDefines.Add(ARSubsystemsDefine);
changed = true;
}
if (!versionDefines.Contains(SpatialTrackingDefine))
{
// Add the spatial tracking #define
versionDefines.Add(SpatialTrackingDefine);
changed = true;
}
#else
if (references.Contains(XRManagementReference))
{
// Remove the reference to the XRManagement replacedembly
references.Remove(XRManagementReference);
changed = true;
}
if (references.Contains(ARSubsystemsReference))
{
// Remove the reference to the ARSubsystems replacedembly
references.Remove(ARSubsystemsReference);
changed = true;
}
if (references.Contains(SpatialTrackingReference))
{
// Remove the reference to the spatial tracking replacedembly
references.Remove(SpatialTrackingReference);
changed = true;
}
#endif
if (changed)
{
asmDef.References = references.ToArray();
#if UNITY_2019_3_OR_NEWER
asmDef.VersionDefines = versionDefines.ToArray();
#endif // UNITY_2019_3_OR_NEWER
asmDef.Save(asmDefFiles[0].FullName);
}
}
19
Source : ListViewCustomBaseEditor.cs
with MIT License
from cschladetsch
with MIT License
from cschladetsch
protected virtual void OnEnable()
{
FillProperties();
if (!IsListViewCustom)
{
IsListViewCustom = DetectGenericType(serializedObject.targetObject, "UIWidgets.ListViewCustom`2");
}
if (!IsTreeViewCustom)
{
IsTreeViewCustom = DetectGenericType(serializedObject.targetObject, "UIWidgets.TreeViewCustom`2");
}
if (IsTreeViewCustom)
{
Properties.Remove("listType");
Properties.Remove("customItems");
Properties.Remove("selectedIndex");
Properties.Remove("direction");
Properties.Remove("loopedList");
}
if (IsListViewCustom)
{
Properties.ForEach(x =>
{
var property = serializedObject.FindProperty(x);
if (property != null)
{
SerializedProperties[x] = property;
}
});
Events.ForEach(x =>
{
var property = serializedObject.FindProperty(x);
if (property != null)
{
SerializedEvents[x] = property;
}
});
}
}
19
Source : DirectoryTreeView.cs
with MIT License
from cschladetsch
with MIT License
from cschladetsch
public virtual TreeNode<FileSystemEntry> GetNodeByPath(string directory)
{
if (!Directory.Exists(directory))
{
return null;
}
var paths = GetPaths(directory);
var nodes = Nodes;
TreeNode<FileSystemEntry> node;
do
{
node = nodes.Find(x => paths.Contains(x.Item.FullName));
if (node == null)
{
return null;
}
paths.Remove(node.Item.FullName);
if (node.Nodes == null)
{
node.Nodes = GetDirectoriesNodes(node.Item.FullName);
}
nodes = node.Nodes;
}
while (directory != node.Item.FullName);
return node;
}
19
Source : CslaTemplateHelper.cs
with MIT License
from CslaGenFork
with MIT License
from CslaGenFork
protected string[] GetNamespaces(CslaObjectInfo info)
{
List<string> usingList = new List<string>();
foreach (ChildProperty prop in info.ChildProperties)
if (prop.TypeName != info.ObjectName)
{
CslaObjectInfo childInfo = FindChildInfo(info, prop.TypeName);
if (childInfo != null)
if (!usingList.Contains(childInfo.ObjectNamespace) && childInfo.ObjectNamespace != info.ObjectNamespace)
usingList.Add (childInfo.ObjectNamespace);
}
foreach (ChildProperty prop in info.InheritedChildProperties)
if (prop.TypeName != info.ObjectName)
{
CslaObjectInfo childInfo = FindChildInfo(info, prop.TypeName);
if (childInfo != null)
if (!usingList.Contains(childInfo.ObjectNamespace) && childInfo.ObjectNamespace != info.ObjectNamespace)
usingList.Add (childInfo.ObjectNamespace);
}
foreach (ChildProperty prop in info.ChildCollectionProperties)
if (prop.TypeName != info.ObjectName)
{
CslaObjectInfo childInfo = FindChildInfo(info, prop.TypeName);
if (childInfo != null)
if (!usingList.Contains(childInfo.ObjectNamespace) && childInfo.ObjectNamespace != info.ObjectNamespace)
usingList.Add (childInfo.ObjectNamespace);
}
foreach (ChildProperty prop in info.InheritedChildCollectionProperties)
if (prop.TypeName != info.ObjectName)
{
CslaObjectInfo childInfo = FindChildInfo(info, prop.TypeName);
if (childInfo != null)
if (!usingList.Contains(childInfo.ObjectNamespace) && childInfo.ObjectNamespace != info.ObjectNamespace)
usingList.Add (childInfo.ObjectNamespace);
}
if (info.ItemType != String.Empty)
{
CslaObjectInfo childInfo = FindChildInfo(info, info.ItemType);
if (childInfo != null)
if (!usingList.Contains(childInfo.ObjectNamespace) && childInfo.ObjectNamespace != info.ObjectNamespace)
usingList.Add (childInfo.ObjectNamespace);
}
if (info.ParentType != String.Empty)
{
CslaObjectInfo parentInfo = FindChildInfo(info, info.ParentType);
if (parentInfo != null)
if (!usingList.Contains(parentInfo.ObjectNamespace) && parentInfo.ObjectNamespace != info.ObjectNamespace)
usingList.Add (parentInfo.ObjectNamespace);
}
//string[] usingNamespaces = new string[usingList.Count];
//usingList.CopyTo(0, usingNamespaces, 0, usingList.Count);
//Array.Sort(usingNamespaces, new CaseInsensitiveComparer());
if (usingList.Contains(string.Empty))
usingList.Remove(string.Empty);
usingList.Sort(string.Compare);
return usingList.ToArray();
}
19
Source : CslaTemplateHelper.cs
with MIT License
from CslaGenFork
with MIT License
from CslaGenFork
protected string[] GetNamespaces(CslaObjectInfo info)
{
var usingList = new List<string>();
if (CurrentUnit.GenerationParams.TargetFramework == TargetFramework.CSLA40 &&
(CurrentUnit.GenerationParams.GenerateAuthorization != Authorization.None &&
CurrentUnit.GenerationParams.GenerateAuthorization != Authorization.PropertyLevel))
{
CslaObjectInfo authzInfo = info;
if (IsCollectionType(info.ObjectType))
{
authzInfo = FindChildInfo(info, info.ItemType);
}
if (authzInfo != null &&
((authzInfo.NewRoles.Trim() != String.Empty) ||
(authzInfo.GetRoles.Trim() != String.Empty) ||
(authzInfo.UpdateRoles.Trim() != String.Empty) ||
(authzInfo.DeleteRoles.Trim() != String.Empty)))
{
usingList.Add("Csla.Rules");
usingList.Add("Csla.Rules.CommonRules");
}
}
if (info.ObjectNamespace.IndexOf(CurrentUnit.GenerationParams.UtilitiesNamespace) != 0)
usingList.Add(CurrentUnit.GenerationParams.UtilitiesNamespace);
foreach (var name in info.Namespaces)
if (!usingList.Contains(name))
usingList.Add(name);
foreach (var prop in info.ChildProperties)
if (prop.TypeName != info.ObjectName)
{
var childInfo = FindChildInfo(info, prop.TypeName);
if (childInfo != null)
if (!usingList.Contains(childInfo.ObjectNamespace) && childInfo.ObjectNamespace != info.ObjectNamespace)
usingList.Add(childInfo.ObjectNamespace);
}
foreach (var prop in info.InheritedChildProperties)
if (prop.TypeName != info.ObjectName)
{
var childInfo = FindChildInfo(info, prop.TypeName);
if (childInfo != null)
if (!usingList.Contains(childInfo.ObjectNamespace) && childInfo.ObjectNamespace != info.ObjectNamespace)
usingList.Add(childInfo.ObjectNamespace);
}
foreach (var prop in info.ChildCollectionProperties)
if (prop.TypeName != info.ObjectName)
{
var childInfo = FindChildInfo(info, prop.TypeName);
if (childInfo != null)
if (!usingList.Contains(childInfo.ObjectNamespace) && childInfo.ObjectNamespace != info.ObjectNamespace)
usingList.Add(childInfo.ObjectNamespace);
}
foreach (var prop in info.InheritedChildCollectionProperties)
if (prop.TypeName != info.ObjectName)
{
var childInfo = FindChildInfo(info, prop.TypeName);
if (childInfo != null)
if (!usingList.Contains(childInfo.ObjectNamespace) && childInfo.ObjectNamespace != info.ObjectNamespace)
usingList.Add(childInfo.ObjectNamespace);
}
if (info.ItemType != String.Empty)
{
var childInfo = FindChildInfo(info, info.ItemType);
if (childInfo != null)
if (!usingList.Contains(childInfo.ObjectNamespace) && childInfo.ObjectNamespace != info.ObjectNamespace)
usingList.Add(childInfo.ObjectNamespace);
}
if (info.ParentType != String.Empty)
{
var parentInfo = FindChildInfo(info, info.ParentType);
if (parentInfo != null)
if (!usingList.Contains(parentInfo.ObjectNamespace) && parentInfo.ObjectNamespace != info.ObjectNamespace)
usingList.Add(parentInfo.ObjectNamespace);
}
//string[] usingNamespaces = new string[usingList.Count];
//usingList.CopyTo(0, usingNamespaces, 0, usingList.Count);
//Array.Sort(usingNamespaces, new CaseInsensitiveComparer());
if (usingList.Contains(string.Empty))
usingList.Remove(string.Empty);
usingList.Sort(string.Compare);
return usingList.ToArray();
}
19
Source : SetStateAtRandomResult.cs
with GNU General Public License v3.0
from CWolfs
with GNU General Public License v3.0
from CWolfs
private void SetStateAtRandom() {
string encounterGuid = EncounterGuids.GetRandom();
EncounterObjectGameLogic encounterGameLogic = UnityGameInstance.BattleTechGame.Combat.ItemRegistry.GereplacedemByGUID<EncounterObjectGameLogic>(encounterGuid);
if (encounterGameLogic != null) {
// A chunk has been disabled by the contract override so ignore it and remove it from the list of choices
if ((encounterGameLogic.StartingStatus == EncounterObjectStatus.ControlledByContract) && (encounterGameLogic.GetState() == EncounterObjectStatus.Finished)) {
Main.LogDebug($"[SetStateAtRandomResult] Avoiding '{encounterGameLogic.gameObject.name}' due to it not being an active chunk in the contract overrides");
EncounterGuids.Remove(encounterGuid);
SetStateAtRandom();
} else {
Main.LogDebug($"[SetStateAtRandomResult] Setting '{encounterGameLogic.gameObject.name}' state '{State}'");
encounterGameLogic.SetState(State);
}
} else {
Main.LogDebug($"[SetStateAtRandomResult] Cannot find EncounterObjectGameLogic with Guid '{encounterGuid}'");
}
}
19
Source : AssetBundleInspectTab.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
internal void AddPath(string newPath)
{
if (!m_BundlePaths.Contains(newPath))
{
var possibleFolderData = FolderDataContainingFilePath(newPath);
if(possibleFolderData == null)
{
m_BundlePaths.Add(newPath);
}
else
{
possibleFolderData.ignoredFiles.Remove(newPath);
}
}
}
19
Source : AssetBundleInspectTab.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
internal void RemovePath(string pathToRemove)
{
m_BundlePaths.Remove(pathToRemove);
}
19
Source : AssetBundleBuildTab.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
internal void OnGUI()
{
m_ScrollPosition = EditorGUILayout.BeginScrollView(m_ScrollPosition);
bool newState = false;
var centeredStyle = new GUIStyle(GUI.skin.GetStyle("Label"));
centeredStyle.alignment = TextAnchor.UpperCenter;
GUILayout.Label(new GUIContent("Example build setup"), centeredStyle);
//basic options
EditorGUILayout.Space();
GUILayout.BeginVertical();
// build target
using (new EditorGUI.DisabledScope (!replacedetBundleModel.Model.DataSource.CanSpecifyBuildTarget)) {
ValidBuildTarget tgt = (ValidBuildTarget)EditorGUILayout.EnumPopup(m_TargetContent, m_UserData.m_BuildTarget);
if (tgt != m_UserData.m_BuildTarget)
{
m_UserData.m_BuildTarget = tgt;
if(m_UserData.m_UseDefaultPath)
{
m_UserData.m_OutputPath = "replacedetBundles/";
m_UserData.m_OutputPath += m_UserData.m_BuildTarget.ToString();
//EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "replacedetBundleOutputPath", m_OutputPath);
}
}
}
////output path
using (new EditorGUI.DisabledScope (!replacedetBundleModel.Model.DataSource.CanSpecifyBuildOutputDirectory)) {
EditorGUILayout.Space();
GUILayout.BeginHorizontal();
var newPath = EditorGUILayout.TextField("Output Path", m_UserData.m_OutputPath);
if (!System.String.IsNullOrEmpty(newPath) && newPath != m_UserData.m_OutputPath)
{
m_UserData.m_UseDefaultPath = false;
m_UserData.m_OutputPath = newPath;
//EditorUserBuildSettings.SetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "replacedetBundleOutputPath", m_OutputPath);
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Browse", GUILayout.MaxWidth(75f)))
BrowseForFolder();
if (GUILayout.Button("Reset", GUILayout.MaxWidth(75f)))
ResetPathToDefault();
//if (string.IsNullOrEmpty(m_OutputPath))
// m_OutputPath = EditorUserBuildSettings.GetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "replacedetBundleOutputPath");
GUILayout.EndHorizontal();
EditorGUILayout.Space();
newState = GUILayout.Toggle(
m_ForceRebuild.state,
m_ForceRebuild.content);
if (newState != m_ForceRebuild.state)
{
if (newState)
m_UserData.m_OnToggles.Add(m_ForceRebuild.content.text);
else
m_UserData.m_OnToggles.Remove(m_ForceRebuild.content.text);
m_ForceRebuild.state = newState;
}
newState = GUILayout.Toggle(
m_CopyToStreaming.state,
m_CopyToStreaming.content);
if (newState != m_CopyToStreaming.state)
{
if (newState)
m_UserData.m_OnToggles.Add(m_CopyToStreaming.content.text);
else
m_UserData.m_OnToggles.Remove(m_CopyToStreaming.content.text);
m_CopyToStreaming.state = newState;
}
}
// advanced options
using (new EditorGUI.DisabledScope (!replacedetBundleModel.Model.DataSource.CanSpecifyBuildOptions)) {
EditorGUILayout.Space();
m_AdvancedSettings = EditorGUILayout.Foldout(m_AdvancedSettings, "Advanced Settings");
if(m_AdvancedSettings)
{
var indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 1;
CompressOptions cmp = (CompressOptions)EditorGUILayout.IntPopup(
m_CompressionContent,
(int)m_UserData.m_Compression,
m_CompressionOptions,
m_CompressionValues);
if (cmp != m_UserData.m_Compression)
{
m_UserData.m_Compression = cmp;
}
foreach (var tog in m_ToggleData)
{
newState = EditorGUILayout.ToggleLeft(
tog.content,
tog.state);
if (newState != tog.state)
{
if (newState)
m_UserData.m_OnToggles.Add(tog.content.text);
else
m_UserData.m_OnToggles.Remove(tog.content.text);
tog.state = newState;
}
}
EditorGUILayout.Space();
EditorGUI.indentLevel = indent;
}
}
// build.
EditorGUILayout.Space();
if (GUILayout.Button("Build") )
{
EditorApplication.delayCall += ExecuteBuild;
}
GUILayout.EndVertical();
EditorGUILayout.EndScrollView();
}
19
Source : SiteObsInfo.cs
with GNU Lesser General Public License v3.0
from czsgeo
with GNU Lesser General Public License v3.0
from czsgeo
internal void RemoveOther(List<ObsTypes> list)
{
List<string> codes = new List<string>();
foreach (var item in list)
{
codes.Add(item.ToString());
}
foreach (var item in ObsCodes)
{
List<string> toRemove = new List<string>();
foreach (var code in item.Value)
{
var fisrtChar = code.Substring(0, 1);
if (!codes.Contains(fisrtChar))
{
toRemove.Add(code);
}
}
foreach (var code in toRemove)
{
item.Value.Remove(code);
}
}
}
19
Source : ObjectTableStorage.cs
with GNU Lesser General Public License v3.0
from czsgeo
with GNU Lesser General Public License v3.0
from czsgeo
public void RemoveCols(IEnumerable<string> colNames)
{
foreach (var name in colNames)
{
NameListManager.Remove(name);
}
foreach (var item in this.BufferedValues)
{
foreach (var name in colNames)
{
item.Remove(name);
}
}
}
19
Source : Action.cs
with MIT License
from dahall
with MIT License
from dahall
internal override string GetPowerShellCommand()
{
// Send-MailMessage [-To] <String[]> [-Subject] <String> [[-Body] <String> ] [[-SmtpServer] <String> ] -From <String>
// [-Attachments <String[]> ] [-Bcc <String[]> ] [-BodyAsHtml] [-Cc <String[]> ] [-Credential <PSCredential> ]
// [-DeliveryNotificationOption <DeliveryNotificationOptions> ] [-Encoding <Encoding> ] [-Port <Int32> ] [-Priority
// <MailPriority> ] [-UseSsl] [ <CommonParameters>]
var bodyIsHtml = Body != null && Body.Trim().StartsWith("<") && Body.Trim().EndsWith(">");
var sb = new System.Text.StringBuilder();
sb.AppendFormat("Send-MailMessage -From '{0}' -Subject '{1}' -SmtpServer '{2}' -Encoding UTF8", Prep(From), ToUTF8(Prep(Subject)), Prep(Server));
if (!string.IsNullOrEmpty(To))
sb.AppendFormat(" -To {0}", ToPS(To));
if (!string.IsNullOrEmpty(Cc))
sb.AppendFormat(" -Cc {0}", ToPS(Cc));
if (!string.IsNullOrEmpty(Bcc))
sb.AppendFormat(" -Bcc {0}", ToPS(Bcc));
if (bodyIsHtml)
sb.Append(" -BodyAsHtml");
if (!string.IsNullOrEmpty(Body))
sb.AppendFormat(" -Body '{0}'", ToUTF8(Prep(Body)));
if (Attachments != null && Attachments.Length > 0)
sb.AppendFormat(" -Attachments {0}", ToPS(Array.ConvertAll(Attachments, o => Prep(o.ToString()))));
var hdr = new List<string>(HeaderFields.Names);
if (hdr.Contains(ImportanceHeader))
{
var p = Priority;
if (p != System.Net.Mail.MailPriority.Normal)
sb.Append($" -Priority {p}");
hdr.Remove(ImportanceHeader);
}
if (hdr.Count > 0)
throw new InvalidOperationException("Under Windows 8 and later, EmailAction objects are converted to PowerShell. This action contains headers that are not supported.");
sb.Append("; ");
return sb.ToString();
/*var msg = new System.Net.Mail.MailMessage(this.From, this.To, this.Subject, this.Body);
if (!string.IsNullOrEmpty(this.Bcc))
msg.Bcc.Add(this.Bcc);
if (!string.IsNullOrEmpty(this.Cc))
msg.CC.Add(this.Cc);
if (!string.IsNullOrEmpty(this.ReplyTo))
msg.ReplyTo = new System.Net.Mail.MailAddress(this.ReplyTo);
if (this.Attachments != null && this.Attachments.Length > 0)
foreach (string s in this.Attachments)
msg.Attachments.Add(new System.Net.Mail.Attachment(s));
if (this.nvc != null)
foreach (var ha in this.HeaderFields)
msg.Headers.Add(ha.Name, ha.Value);
var client = new System.Net.Mail.SmtpClient(this.Server);
client.Send(msg);*/
}
19
Source : MMIScene.cs
with MIT License
from Daimler
with MIT License
from Daimler
private MBoolResponse RemoveAvatars(List<string> avatarIDs, bool deepCopy)
{
MBoolResponse result = new MBoolResponse(true);
//Iterate over each scene object
foreach (string id in avatarIDs)
{
//Find the object
if (avatarsByID.ContainsKey(id))
{
string avatarName = avatarsByID[id].Name;
//Remove the mapping
if (nameIdMappingAvatars.ContainsKey(avatarName))
{
nameIdMappingAvatars[avatarName].Remove(id);
}
//Remove the scene object from the dictionary
avatarsByID.TryRemove(id, out MAvatar avatar);
}
}
return result;
}
19
Source : MMIScene.cs
with MIT License
from Daimler
with MIT License
from Daimler
private MBoolResponse RemoveSceneObjects(List<string> sceneObjectIDs, bool deepCopy)
{
MBoolResponse result = new MBoolResponse(true);
//Iterate over each scene object
foreach (string id in sceneObjectIDs)
{
//Find the object
if (sceneObjectsByID.ContainsKey(id))
{
string sceneObjectName = sceneObjectsByID[id].Name;
//Remove the mapping
if (nameIdMappingSceneObjects.ContainsKey(sceneObjectName))
{
nameIdMappingSceneObjects[sceneObjectName].Remove(id);
}
//Remove the scene object from the dictionary
sceneObjectsByID.TryRemove(id, out MSceneObject sceneObject);
}
}
return result;
}
19
Source : DungeonGeneratorEditor.cs
with MIT License
from damarindra
with MIT License
from damarindra
public override void OnInspectorGUI()
{
if (GUILayout.Button("Generate"))
{
dg.StartRoomGeneration();
}
if (GUILayout.Button("Toggle Gizmos"))
{
dg.drawGizmos = !dg.drawGizmos;
}
if(GUILayout.Button("Toggle Debug Mode"))
{
string definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
List<string> allDefines = definesString.Split(';').ToList();
if (allDefines.Contains("DEBUG_MODE"))
{
allDefines.Remove("DEBUG_MODE");
}
else
{
allDefines.Add("DEBUG_MODE");
}
PlayerSettings.SetScriptingDefineSymbolsForGroup(
EditorUserBuildSettings.selectedBuildTargetGroup,
string.Join(";", allDefines.ToArray()));
}
/*
if (GUILayout.Button("Visualize With Collider"))
{
dg.CreateColliderVisual();
}
if (GUILayout.Button("Remove All Collider Visualization"))
{
dg.DeleteAllColliderVisual();
}*/
base.OnInspectorGUI();
}
19
Source : LocalLockTracker.cs
with MIT License
from danielgerlag
with MIT License
from danielgerlag
public void Remove(string id)
{
_mutex.WaitOne();
try
{
_localLocks.Remove(id);
}
finally
{
_mutex.Set();
}
}
19
Source : StateProvider.cs
with Apache License 2.0
from danielcrenna
with Apache License 2.0
from danielcrenna
private static void SetupStateMachineTypeRecursive(
IDictionary<Type, Dictionary<Type, State>> stateMachinesToStates,
IDictionary<Type, Dictionary<Type, MethodTable>> stateMachinesToAbstractStates,
Type stateMachineType)
{
Debug.replacedert(typeof(StateProvider).IsreplacedignableFrom(stateMachineType));
if (stateMachinesToStates.ContainsKey(stateMachineType)) return;
Dictionary<Type, State> baseStates = null;
Dictionary<Type, MethodTable> baseAbstractStates = null;
if (stateMachineType != typeof(StateProvider))
{
SetupStateMachineTypeRecursive(stateMachinesToStates, stateMachinesToAbstractStates,
stateMachineType.BaseType);
baseStates =
stateMachinesToStates[
stateMachineType.BaseType ??
throw new InvalidOperationException($"{nameof(MethodTable)} base type not found")];
baseAbstractStates = stateMachinesToAbstractStates[stateMachineType.BaseType];
}
const BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |
BindingFlags.DeclaredOnly;
var typeMethods = stateMachineType.GetMethods(bindingFlags);
var stateMethods = typeMethods.ToDictionary(mi => mi.Name);
var newStateTypes = stateMachineType.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic)
.Where(nt => typeof(State).IsreplacedignableFrom(nt)).ToArray();
foreach (var newStateType in newStateTypes)
{
var newStateTypeMethods = newStateType.GetMethods(bindingFlags);
foreach (var newStateTypeMethod in newStateTypeMethods)
{
var methodName = GetFullyQualifiedStateMethodName(newStateTypeMethod);
if (stateMethods.ContainsKey(methodName))
{
var duplicateMethods = new List<string> {methodName};
if (methodName.StartsWith(StateDisambiguatorPrefix))
{
var naturalName = methodName.Replace(StateDisambiguatorPrefix, string.Empty);
if (stateMethods.ContainsKey(naturalName)) duplicateMethods.Add(naturalName);
}
throw new DuplicateStateMethodException(duplicateMethods.ToArray());
}
stateMethods.Add(methodName, newStateTypeMethod);
}
}
Type methodTableType;
var methodTableSearchType = stateMachineType;
while ((methodTableType =
methodTableSearchType?.GetNestedType(nameof(MethodTable),
BindingFlags.Public | BindingFlags.NonPublic)) == null)
{
if (!typeof(StateProvider).IsreplacedignableFrom(methodTableSearchType?.BaseType)) break;
methodTableSearchType = methodTableSearchType?.BaseType;
}
if (methodTableType == null)
throw new InvalidOperationException($"{nameof(MethodTable)} not found for {stateMachineType}");
if (!typeof(MethodTable).IsreplacedignableFrom(methodTableType))
throw new InvalidOperationException(
$"{nameof(MethodTable)} must be derived from StateMachine.MethodTable");
var states = new Dictionary<Type, State>();
var abstractStates = new Dictionary<Type, MethodTable>();
Debug.replacedert(baseStates != null == (baseAbstractStates != null));
if (baseStates != null)
{
foreach (var baseState in baseStates)
{
var state = (State) Activator.CreateInstance(baseState.Key);
state.methodTable =
ShallowCloneToDerived(baseState.Value.methodTable, methodTableType, stateMachineType);
FillMethodTableWithOverrides(baseState.Key, state.methodTable, stateMachineType, stateMethods);
states.Add(baseState.Key, state);
}
foreach (var baseAbstractState in baseAbstractStates)
{
var methodTable = ShallowCloneToDerived(baseAbstractState.Value, methodTableType, stateMachineType);
FillMethodTableWithOverrides(baseAbstractState.Key, methodTable, stateMachineType, stateMethods);
abstractStates.Add(baseAbstractState.Key, methodTable);
}
}
foreach (var stateType in newStateTypes)
SetupStateTypeRecursive(states, abstractStates, stateType, stateMachineType, methodTableType,
stateMethods);
var stateTypesToMethodTables = states
.Select(kvp => new KeyValuePair<Type, MethodTable>(kvp.Key, kvp.Value.methodTable))
.Concat(abstractStates).ToList();
foreach (var typeToMethodTable in stateTypesToMethodTables)
{
var methodTable = typeToMethodTable.Value;
var allMethodTableEntries = methodTable.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance)
.Where(fi => fi.FieldType.BaseType == typeof(MulticastDelegate)).ToList();
if (!allMethodTableEntries.Any()) stateMethods.Clear();
var toRemove = new List<string>(stateMethods.Keys);
foreach (var fieldInfo in allMethodTableEntries)
foreach (var stateMethod in stateMethods)
{
var ignore = stateMethod.Value.GetCustomAttributes(typeof(IgnoreStateMethodAttribute), false);
if (ignore.Length > 0) continue;
var aliasName = $@"{fieldInfo.Name}";
var disambiguatedName = $@"{StateDisambiguatorPrefix}_\w*_{fieldInfo.Name}";
var naturalName = $@"\w*_{fieldInfo.Name}";
if (Regex.IsMatch(stateMethod.Key, disambiguatedName) ||
Regex.IsMatch(stateMethod.Key, naturalName) ||
stateMethod.Key == aliasName)
toRemove.Remove(stateMethod.Key);
}
foreach (var stateMethod in toRemove) stateMethods.Remove(stateMethod);
}
if (stateMethods.Count > 0) throw new UnusedStateMethodsException(stateMethods.Values);
foreach (var typeToMethodTable in stateTypesToMethodTables)
{
var methodTable = typeToMethodTable.Value;
var allMethodTableEntries = methodTable.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance)
.Where(fi => fi.FieldType.BaseType == typeof(MulticastDelegate));
foreach (var fieldInfo in allMethodTableEntries)
{
if (fieldInfo.GetCustomAttributes(typeof(AlwaysNullCheckedAttribute), true).Length != 0) continue;
if (fieldInfo.GetValue(methodTable) == null)
{
var methodInMethodTable = fieldInfo.FieldType.GetMethod("Invoke");
Debug.replacedert(methodInMethodTable != null, nameof(methodInMethodTable) + " != null");
var dynamicMethod = new DynamicMethod(
$"DoNothing{Separator}{GetStateName(typeToMethodTable.Key)}{Separator}{fieldInfo.Name}",
methodInMethodTable.ReturnType,
methodInMethodTable.GetParameters().Select(pi => pi.ParameterType).ToArray(),
stateMachineType);
var il = dynamicMethod.GetILGenerator();
EmitDefault(il, methodInMethodTable.ReturnType);
il.Emit(OpCodes.Ret);
fieldInfo.SetValue(methodTable, dynamicMethod.CreateDelegate(fieldInfo.FieldType));
}
}
}
stateMachinesToStates.Add(stateMachineType, states);
stateMachinesToAbstractStates.Add(stateMachineType, abstractStates);
}
See More Examples